get_users – Sort by a different meta_value than search criteria

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 );

members only products

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

Return all users that have one or more published blog posts

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

How do I delete a wordpress user from giant database?

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.

Auto approve new users if their username is included in a predefined list

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 ); } } }

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