WordPress display name string manipulation
Use PHP’s substr() function: $outcome = trim( get_user_meta( $user->ID, ‘first_name’, true ) . ‘ ‘ . substr( get_user_meta( $user->ID, ‘last_name’, true ), 0, 1 ) . ‘.’ );
Use PHP’s substr() function: $outcome = trim( get_user_meta( $user->ID, ‘first_name’, true ) . ‘ ‘ . substr( get_user_meta( $user->ID, ‘last_name’, true ), 0, 1 ) . ‘.’ );
It sounds like you are updating the user information after the form has been displayed. You need to rearrange your code so that you are updating the user information earlier, before the form is displayed. If you need help figuring out how to do that, then you need to share some more details about how … Read more
I think your idea is good: create a function that hook ‘show_user_profile’ and ‘edit_user_profile’ action. In this function use a conditional to show a textarea only for admins and the content of this textarea (saved as user meta) to the owner of the profile. Something like (very rough and untested): function custom_profile_content ( $user ) … Read more
use single form to enter multiple profiles
If you never heard of WordPress, you can have an overview at the Codex in Getting Started with WordPress and explore the topics as the need arrives. G.M’s linked Answer has very nice information for your use-case, and sample code with advanced techniques. Worth bookmarking. To get really started, learn how to make a Child … Read more
Here is how I would do it: function save_extra_user_profile_fields( $user_id ) { if (!isset($_POST[‘address’]) || empty($_POST[‘address’])) { // this field was not set or was empty // do your action wp_redirect( home_url() ); // or profile page exit; } else { // field was set and contains a value // do your action update_user_meta( $user_id, … Read more
According to the Codex, get_user_id_from_string() is deprecated, and should be replaced with get_user_by(). <p> <?php $thisblog = get_current_blog_id(); // probably don’t need this anymore $admin_email = trim( get_option( ‘admin_email’ ) ); $admin_user = get_user_by( ’email’, $admin_email ) ); $phone_number = get_user_meta($admin_user->ID, ‘phone’, true); if($phone_number!=”) { ?> <?php echo $phone_number; ?> <?php } else { ?> … Read more
How to create a link to a user’s profile page
Create nonce in frontend page to edit profile
Fetching posts that match a User Profile setting