How to Merge Two Authors Into One?

Yes, this is a good question and the answer is basic WordPress 101 (core), contrary to the two comments above. No plugin necessary. You simply go to Users and delete the author (user) that you don’t want to keep. WordPress then asks you if you want to delete their content or attribute it to another … Read more

Confirmation required on email change

Like SickHippie posted this functionality is native to WordPress but only for a multisite setup so here is the two functions you need to get this to work on a single site setup which are mostly code one for one from the core /wp-admin/user-edit.php file function custom_send_confirmation_on_profile_email() { global $errors, $wpdb; $current_user = wp_get_current_user(); if … Read more

get_user_meta() doesn’t include user email?

get_user_meta retrieves a single meta field or all fields of the user_meta data for the given user. This means that all the values that are stored in user_meta table can be got using get_user_meta. Email is not stored as meta data so you cant get email using get_user_meta. Email is stored with username and password … Read more

Get multiple roles with get_users

Fastforward to WordPress 4.4 – it will support the role__in attribute! It looks like WordPress 4.4 is our lucky version number, because it will support both the role__in and role__not_in attributes of the WP_User_Query class. So to include the subscriber, contributor and author roles, we can simply use: $users = get_users( [ ‘role__in’ => [ … Read more

Display user registration date

get_current_user_id() give you the user id of the logged in user. And that is: you. You have to get all users: <?php $users = get_users(); foreach( $users as $user ) { $udata = get_userdata( $user->ID ); $registered = $udata->user_registered; printf( ‘%s member since %s<br>’, $udata->data->display_name, date( “M Y”, strtotime( $registered ) ) ); }

How to get WordPress Username in Array format

The other answers are correct, but it’s possible to achive the same thing with less code using wp_list_pluck(): $users = get_users(); $user_names = wp_list_pluck( $users, ‘display_name’ ); wp_list_pluck() used that way will get the display_name field of all the users in an array without needing to do a loop.

Make WooCommerce pages accessible for logged in users only

Put this in your functions.php file: function wpse_131562_redirect() { if ( ! is_user_logged_in() && (is_woocommerce() || is_cart() || is_checkout()) ) { // feel free to customize the following line to suit your needs wp_redirect(home_url()); exit; } } add_action(‘template_redirect’, ‘wpse_131562_redirect’); What does it do? We check if a not-logged-in user wants to see a WooCommerce page, … Read more