Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

PHP If statement WordPress

  • SOLVED

Look at this PHP file:

https://github.com/restrictcontentpro/restrict-content-pro/blob/master/templates/register-total-details.php

It includes the following:

<tr class="rcp-total">
<th><?php _e( 'Total Today', 'rcp' ); ?></th>
<th><?php rcp_registration_total(); ?></th>
</tr>


I want that part to show only if the user is logged in.

So I need to do a check for

if ( is_user_logged_in() )

then show that code.

If user is not logged in, skip that part of the code.

What do I change?

Thanks.

Answers (3)

2017-01-06

Arnav Joy answers:

here it is


<?php if ( is_user_logged_in() ) { ?>

<tr class="rcp-total">
<th><?php _e( 'Total Today', 'rcp' ); ?></th>
<th><?php rcp_registration_total(); ?></th>
</tr>

<?php } ?>

2017-01-06

Sébastien | French WordpressDesigner answers:

if ( is_user_logged_in() ) { ?>
<tr class="rcp-total">
<th><?php _e( 'Total Today', 'rcp' ); ?></th>
<th><?php rcp_registration_total(); ?></th>
</tr>
<?php }


Sébastien | French WordpressDesigner comments:

arnav code is better

2017-01-06

Rempty answers:

<tr class="rcp-total">
<th><?php _e( 'Total Today', 'rcp' ); ?></th>
<th><?php rcp_registration_total(); ?></th>
</tr>
Replace with
<?php
if ( is_user_logged_in() ){
?>
<tr class="rcp-total">
<th><?php _e( 'Total Today', 'rcp' ); ?></th>
<th><?php rcp_registration_total(); ?></th>
</tr>
<?php
}
?>