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 filter users on admin users page by custom meta field?

UPDATE 2018-06-28 While the code below mostly works fine, here is a rewrite of the code for WP >=4.6.0 (using PHP 7): function add_course_section_filter( $which ) { // create sprintf templates for <select> and <option>s $st=”<select name=”course_section_%s” style=”float:none;”><option value=””>%s</option>%s</select>”; $ot=”<option value=”%s” %s>Section %s</option>”; // determine which filter button was clicked, if any and set section … Read more

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.

How do I programmatically set default role for new users?

This allows plugins to easily hijack the default role while they’re active. // Hijack the option, the role will follow! add_filter(‘pre_option_default_role’, function($default_role){ // You can also add conditional tags here and return whatever return ‘subscriber’; // This is changed return $default_role; // This allows default }); I use it to make sure some plugins that … Read more

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

Make display name unique

As far as I’m aware, all you can do is filter the display name via pre_user_display_name and check if it already exists. Unfortunately WP_User_Query doesn’t support querying by display_name, so we also have to add to the WHERE clause via pre_user_query. Additionally, there is no elegant way I can think of to handle the case … Read more

Where can I find documentation on what characters are allowed in user names and why?

You can use spaces in usernames, no problem. Several users on wordpress.org have spaces in their usernames. Strict mode only allows these characters: a-z0-9<space>_.\-@ However WP doesn’t default to strict mode. Now, multisite has different restrictions, and it may strip spaces there. This is because usernames are used to create independent blogs and such on … Read more

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