New answers tagged


For those which have multilingual site, function function wp_roles_array() { $editable_roles = get_editable_roles(); foreach ($editable_roles as $role => $details) { $sub['role'] = esc_attr($role); $sub['name'] = translate_user_role($details['name']); $roles[] = $sub; } return $roles; } returns localized array ...


I suggest not to mess with the existing roles and capabilities in its default, it might help you some trouble when you will have a bunch of custom roles and capabilities in the future. To answer your question, I will have an example: I need new role/user group that has almost an Administrator but don't have the the capability to edit plugins and the ...


pre_get_users is the action that is fired before a user query is run. You need to check the context of the action to make sure you're on the main users screen. You can then alter the query with any parameters accepted by WP_User_Query. A quick example: function wpd_filter_users( $query ) { $screen = get_current_screen(); if( is_admin() && ...


After digging deeper, and checking on my end, I found this script will work just fine. $userdata = array( 'user_login' => $username, 'user_email' => $email, 'user_pass' => $password, 'user_url' => $website, 'first_name' => $first_name, 'last_name' => $last_name, 'nickname' => $nickname, 'description' ...


I think you are on the right track, wp_cache_delete was what finally helped me get an auto-signup with auto-login plugin working... I have this from there: wp_cache_delete($current_user->ID, 'users'); wp_cache_delete($current_user->user_login, 'userlogins'); Then see what roles you get after that with: $current_user = wp_get_current_user();


Have you tried logging in the user after your changes? Such as: wp_set_current_user( $current_user->ID, $current_user->user_login ); wp_set_auth_cookie( $current_user->ID ); do_action( 'wp_login', $current_user->user_login );


RESOLVED!! It was me missing a trick within Role Scoper. All sorted! Thanks Mukto90 and Monkey Puzzle for your input. Cheers! Andy

Top 50 recent answers are included