If statement
-
Hi there
i am relatively new to php and server side scripting. I am trying to include an if/if else statement in of my pages on my wordpress website.
i am using the replacement shortcode ‘[insert_php]’ and ‘[/insert_php]’ instead of the php beginning header and footer.
What i would like to do is get the current users username and then just display some text if it is==’admin’. If the user name is==’volunteer’ display some other text.
What i have so far is:
[insert_php]
$current_user=wp_get_current_user();
echo $current_user->user_login . ‘
‘;
[/insert_php]This just displays the username of the user logged in but how do i include an if/if else statement? I have tried multiple iterations such as below with no success.
[insert_php]
$current_user=wp_get_current_user();
[/insert_php]
[insert_php]
if($current_user==’admin’) :
echo $current_user->user_login . ‘
‘;
endif;
[/insert_php]
- The topic ‘If statement’ is closed to new replies.