Hide a user from WordPress

You’re wanting to hide a user from WordPress in three places: The user list in the admin The count above that user list The user’s author archive on the front-end As you mentioned, you’ve already solved item 1 and you’ve included the code for that. So, I’ll provide the solutions for items 2 and 3. … Read more

how to get recent registered author id?

I don’t think you need any SQL queries. <?php $args = array( ‘role’ => ‘author’, // authors only ‘orderby’ => ‘registered’, // registered date ‘order’ => ‘DESC’, // last registered goes first ‘number’ => 1 // limit to the last one, not required ); $users = get_users( $args ); $last_user_registered = $users[0]; // the first … Read more

How to edit user_id on the comment edit screen

You can take reference from below code. It will provide an option to update user id of comment (https://prnt.sc/s57q4f). paste below code in active theme’s functions.php file.I have tested and it is working for me. let me know if it works for you. # comment user id update metabox function action_add_meta_boxes_comment( $comment ) { ?> … Read more

How to get the Role Name of the current user? (WordPress)

I’m not sure if bbPress follows WordPress conventions, but WP has a global class called $WP-roles that holds the role information. So, starting from what you have, there is the role of the current user: $current_role = $user->roles[1]; Next, retrieve a list of all roles: $all_roles = $wp_roles->roles; Then, loop through $all_roles and find the … Read more

get_userdata by username

get_userdata() function is an alias of get_user_by(‘ID’) function. Use this code: $username=”your user name”; $user = get_user_by(‘login’, $username); It will return WP_User object on success, or false on failure. See Codex. REST API: http://example.com/wp-json/wp/v2/users/<id>