if $current_user->first_name is null how to show $current_user->user_login ???
-
Hey guys, how would you write this in a function..
Basically I want to echo the first name but if field is empty to show user name or user id instead..
This is what I have..
// Callback function for displaying admin messages @return calls jraba_show_msg() function jraba_admin_msgs() { global $jraba_settings_pg = strpos($_GET['page'], JRABA_PAGE_BASENAME); $jraba_errors = get_settings_errors(); $current_user; get_currentuserinfo(); //display admin message only for the admin to see, only on our settings page and only when setting errors/notices are returned! if(current_user_can ('manage_options') && $jraba_settings_pg !== FALSE && !empty($jraba_errors)){ // have our settings succesfully been updated? if($jraba_errors[0]['code'] == 'settings_updated' && isset($_GET['settings-updated'])){ jraba_show_msg("<p>" . $update_message = 'Hey ' . $current_user->first_name . ', your settings have been successfully updated. Why don\'t you hover over the menu to ensure that your options are either ON or OFF.' . "</p>", 'updated'); // have errors been found? }else{ foreach($jraba_errors as $jraba_error){ // set the title attribute to match the error "setting title" - need this in js file jraba_show_msg("<p class='setting-error-message' title='" . $jraba_error['setting'] . "'>" . $jraba_error['message'] . "</p>", 'error'); } } } } function jraba_show_msg($message, $msgclass = 'info') { echo "<div id='message' class='$msgclass'>$message</div>"; } if ' . $current_user->first_name . ' empty show ' $current_user->user_login . '
Now if you look under $update_message you will see my update message “Hey ‘ . $current_user->first_name . ‘, your settings have been successfully updated. Why don\’t you hover over the menu to ensure that your options are either ON or OFF.”
The $current_user->first_name will echo out the first name, which works good, but what if the user does not have the first name field filled out, I would like it to echo out if $current_user->user_login if the first name is not available..
How would you do this?
- The topic ‘if $current_user->first_name is null how to show $current_user->user_login ???’ is closed to new replies.