{"id":3291891,"date":"2012-12-19T15:48:14","date_gmt":"2012-12-19T15:48:14","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/if-statement-4\/"},"modified":"2016-08-20T19:17:31","modified_gmt":"2016-08-20T19:17:31","slug":"if-statement-4","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/if-statement-4\/","title":{"rendered":"If statement"},"content":{"rendered":"<p>Hi there <\/p>\n<p>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. <\/p>\n<p>i am using the replacement shortcode &#8216;[insert_php]&#8217; and &#8216;[\/insert_php]&#8217; instead of the php beginning header and footer. <\/p>\n<p>What i would like to do is get the current users username and then just display some text if it is==&#8217;admin&#8217;. If the user name is==&#8217;volunteer&#8217; display some other text.<\/p>\n<p>What i have so far is:<\/p>\n<p>[insert_php]<br \/>\n$current_user=wp_get_current_user();<br \/>\necho $current_user-&gt;user_login . &#8216;<br \/>&#8216;;<br \/>\n[\/insert_php]<\/p>\n<p>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.<\/p>\n<p>[insert_php]<br \/>\n$current_user=wp_get_current_user();<br \/>\n[\/insert_php]<br \/>\n[insert_php]<br \/>\nif($current_user==&#8217;admin&#8217;) :<br \/>\necho $current_user-&gt;user_login . &#8216;<br \/>&#8216;;<br \/>\nendif;<br \/>\n[\/insert_php]<\/p>\n<p>https:\/\/wordpress.org\/extend\/plugins\/insert-php\/<\/p>\n","protected":false},"template":"","class_list":["post-3291891","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/3291891","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/3291891\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=3291891"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}