How can I prevent certain custom roles from seeing other custom roles on the user list page?

Method 1, SQL Notes about your SQL [Unknown column ‘wp_usermeta.meta_key’ in ‘where clause’] This is solved by adding this to the JOIN part of the query: JOIN wp_usermeta ON ( wp_usermeta.user_id = wp_users.ID ) You could check the value of the JOINS and, if false === strpos( ‘wp_usermeta’, $joins ), adding it yourself. When getting … Read more

How to get the count

You should use a total_users property: $query = new WP_User_Query( $args ); $query->total_users; or get_total method: $query = new WP_User_Query( $args ); $query-> get_total(); Docs are your friend: https://codex.wordpress.org/Class_Reference/WP_User_Query

is_user_logged_in() throwing undefined function error

It’s failing because WordPress isn’t loaded. Instead of making AJAX requests directly to PHP files in your theme, make them to a REST API endpoint. For example: add_action( ‘rest_api_init’, function () { register_rest_route( ‘petebolduc/v1’, ‘/test/’, array( ‘callback’ => ‘petebolduc_ajax’ ) ); } ); function petebolduc( $parameters ) { $foo = $parameters[‘foo’]; return “foo is ” … Read more

How to combine two get_users() array?

Edit: to clarify, the answer to How can I merge them together for results? Is that you really can’t, not without a lot of custom SQL and using filters. The complexity of going that route far outweighs any perceived benefits and wouldn’t be very future-proof. I’d recommend using the solution below and putting it all … Read more

Randomize Users

I don’t see an “orderby Rand()” parameter for either get_users or WP_User_Query. There is a filter called pre_user_query that could be used but I am not sure I see the benefit of that when shuffle will randomize the array you already have. $args = array( ‘fields’ => ‘all_with_meta’, ‘exclude’ => array(1), ); $users = get_users( … Read more

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