Get all wp_users sort by metakey

You can index each of the arrays and then orderby 1 or both of them using ASC,DESC as per your requirement $meta_query_args = array( ‘relation’ => ‘OR’, // Optional, defaults to “AND” ‘no_login’ =>array( ‘key’ => ‘user_last_login’, ‘compare’ => ‘Not Exists’ ), ‘login’ => array( ‘key’ => ‘user_last_login’, ‘compare’ => ‘Exists’ ) ); $meta_query = … Read more

Hide top admin panel for non admin and non editors

This is what i am using; add_action(‘init’, ‘blockusers_init’); function blockusers_init() { if (is_admin() && !current_user_can(‘administrator’) && !(defined(‘DOING_AJAX’) && DOING_AJAX)) { wp_redirect(home_url()); exit; } } It’s possible the best one. EDIT : You need a custom login page for reach wp-admin. This code redirect to homepage if you enter directly to wp-admin.

wp list all users who haven’t commented on a post

OK, so you want to get set complements from MySQL. One way to do this will be with query like that: SELECT u.ID FROM wp_users u LEFT OUTER JOIN wp_comments c ON (u.ID = c.user_id AND comment_post_ID = <YOUR_POST_ID>) WHERE c.user_id is null But you should remember, that such query won’t be very efficient. So … Read more

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