If logged in user views his profile page

You can make use of the get_current_user_id(), get_the_author_meta(‘ID’), and get_edit_user_link() functions. Take the below snippet for instance: if( get_current_user_id() === get_the_author_meta(‘ID’) ){ printf( ‘<a href=”https://wordpress.stackexchange.com/questions/314019/%s”>Edit Profile</a>’, get_edit_user_link() ); } get_current_user_id() will return int(0) if nobody is logged in, or the integer ID of the current user. This effectively removes the need for is_user_logged_in(). get_the_author_meta(‘ID’) will … Read more

Show extra user profile meta for current user

You should use get_user_meta instead of get_the_author_meta(). because get_the_author_meta() has Valid values for the $field parameter include: get_the_author_meta you can take reference from below code. $school_id = get_user_meta( $current_user->ID, ‘school-id’,true); if ( !empty($school_id) ) { ?> <p class=”school-id”> <p> <?php echo $school_id; # what you want to do with school id ?> </p> </p> <?php … Read more

Using WP for user management

You might want to take a look at the REST API that comes out of the box with WordPress. Here are the docs for Users, you can register users and list/retrieve/update them https://developer.wordpress.org/rest-api/reference/users/ Here’s the information about how to authenticate to use the API (so that you can Reigister Users for instance) https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/

Combining wp_list_authors with get_user_meta

What you want is not supported by wp_list_authors(). To output them the way you want you will need to use get_users() and display them yourself. $authors = get_users( array( ‘orderby’ => ‘display_name’, ‘order’ => ‘ASC’ ) ); foreach ( $authors as $author ) { echo esc_html( $author->last_name . ‘ ‘ . $author->first_name ); } You … Read more

editing usermeta when field is an array

This code is your problem: $s2_custom=get_user_meta($u->ID, ‘wp_s2member_custom_fields’); $real = $s2_custom[0]; $real[‘loomsong_del’]=’email’; update_user_meta($u->ID, ‘wp_s2member_custom_fields’,$real); get_user_meta returns an array of the meta values. Since in this case there’s only a single value with the array, you need to pass the single parameter to it. Try this: $s2_custom=get_user_meta($u->ID, ‘wp_s2member_custom_fields’, true); $s2_custom[‘loomsong_del’]=’email’; update_user_meta($u->ID, ‘wp_s2member_custom_fields’,$s2_custom); This won’t fix your already … Read more

How to add to a user_meta field (append)

Use get_user_meta(): $original = get_user_meta( $user->ID, ‘purchase_history’, TRUE ); echo $original . ‘ Pancake Breakfast 05/15/2005’; To update the value use update_user_meta(): update_user_meta( $user->ID, ‘purchase_history’, $original . ‘Pancake Breakfast 05/15/2005’ );

Test if key is in user_meta array

First of all, I believe your syntax is incorrect. Should be: $group = ‘_mm_group_membership’; // key should be a string Secondly, did you try using $u->get? Here’s what the doc says: If fields is set to all_with_meta, it will return an array of WP_User objects. So yes, if you specified this parameter you should get … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)