Extending WP_User class and using this sub-class during the whole lifecycle

If I did understand well, we need to cache a value retrieved from another REST service, from the login to logout of the user on the wordpress installation, so we will hook into this wp_login to get the value and cache it using Transient API, Options API or a persistent caching plugin. add_action(‘wp_login’, ‘my_get_and_cache_rest_value’); function … Read more

Change user’s display name programmatically

Just pasted your code into my functions.php with a different ID and checked the user’s page in /wp-admin/user-edit.php – it works, the value in Display name publicly as field is updated. Most likely something is wrong with your output on the user page. Check your template file. Or, if you can’t find the problem, edit … Read more

Importing users? From another wordpress site

I think you have two options (third if you find any plugins). I think if you export data from one WP, the users are also copied. The drawback is that you have to import all the content as well. The second option is to export the users from MySQL using PHPMyAdmin. Just export the user … Read more

‘username_exists’ still returns an ID even after deleting record from the database?

By default, WordPress uses $wp_object_cache which is an instance of WP_Object_Cache to save on trips to the database. Trace back username_exists() function, you will notice that get_user_by() uses WP_User::get_data_by() which return user data from $wp_object_cache immediately without checking if that user exists in database. Note that $wp_object_cache is stored in memory. It means that if … Read more

Post list based on the user that is logged in

there you go, i’m not the only one trying to bring back-end functionality to the front-end. anyway its not that hard go to your “USER DASHBOARD” template’s file and locate where the loop starts something like: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> and just above it paste this … Read more

How can I run a WP-CLI command as authenticated user?

By default WP-CLI executes every command as unauthenticated (logged-out) user. To execute a command as any existing WordPress user you can use the global –user parameter, which accepts an user ID, login, or email address. $ wp nurse check –all –user=1 You’ll get all other global parameters listed when running $ wp –help or $ … Read more