fine-grained capabilities for user related capabilities
fine-grained capabilities for user related capabilities
fine-grained capabilities for user related capabilities
How to prevent deleteting specific user?
Direct modification of WP database is a very bad idea. In your case, you have problem because you avoid caching. WordPress caches almost everything what is able to cache, and user data are not the exclusion. When you call username_exists(), it returns information from the cache, not from the database. You should use wp_update_user() to … Read more
Should be ‘meta_key’ => ‘last_name’ instead of ‘meta_key’ => ‘user_lastname’ $args = array( ‘meta_query’ => array( array( ‘key’ => ‘pw_user_status’, ‘value’ => ‘approved’ , ), ), ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘last_name’, ‘order’ => ‘ASC’ ); $users = get_users( $args );
Use this code on your child theme’s functions.php file.. //Hide for non-logged-in users (public visitors) function bp_logged_out_page_template_redirect() { if( ! is_user_logged_in() && is_page( ‘members’ ) || is_page( ‘activity’ ) || bp_is_user() ) { wp_redirect( home_url( ‘/register/’ ) ); exit(); } } add_action( ‘template_redirect’, ‘bp_logged_out_page_template_redirect’ ); The above snippet will do: •IF the user is not … Read more
You can use the REST API to list users: /wp-json/wp/v2/users Add that to the end of your website URL. Plugins such as Wordfence can prevent anonymous users from accessing this. You can also disable the REST API if you do not use it.
There is an argument for this, and it is documented. If you look at the documentation for get_users() is says this: See WP_User_Query::prepare_query(). for more information on accepted arguments. If you follow that link you’ll see the list of arguments, and one of those is: ‘has_published_posts’ (bool|array) Pass an array of post types to filter … Read more
Using WP CLI, you can easily delete users without concerns about loading the WordPress UI. wp user delete is the command you’re looking for. In your case, use wp user delete 123 –reassign=567 for deleting a user by ID and reassigning to another user.
You might put this code in functions.php : $GLOBALS[‘allowed_users’]= [‘mikejordan’, ‘jamesbrown’, …]; add_action(‘user_register’,’my_function’); function my_function($user_id){ // get user data $user_info = get_userdata($user_id); if ( in_array($user_info->login, $GLOBALS[‘allowed_users’] ) ) { $res = $wpdb->query($wpdb->prepare(“SELECT activation_key from {$wpdb->signups} WHERE user_login = %s)”, $user_info->login)); if (!empty($res)) { wpmu_activate_signup( $res->activation_key ); } } }
How to make custom user profile page public?