get_users() timeout on big userbase — options to divide query?

You are on the right track with the batch idea. You’ll need a combination of parameters in your get_users() call. A combination of the “number” and “offset” parameters should get you what you need. In the example below $count is a reference to the batch that’s currently running. <?php // inside a loop where $count … Read more

Updating user meta

One of two functions you’ll need; update_user_meta or add_user_meta – more often than not you’ll just need the former, but it’s worth noting the difference: add_post_meta will only create an entry if the $unique parameter is false, or if there is no existing data for $meta_key. update_post_meta will add if no data exists yet, otherwise … Read more

Sort users by userID by default on users.php

You can use pre_get_users since WP 4.0.0 function my_user_sort( $query_args ){ if( is_admin() && !isset($_GET[‘orderby’]) ) { $query_args->query_vars[‘orderby’] = ‘ID’; } return $query_args; } add_action( ‘pre_get_users’, ‘my_user_sort’ );

*wpupdateuser* user_login in my WordPress database

wpupdateuser does not appear correct. Is it a compromise? Possibly not if you are allowing user registrations. A Google search for wpupdateuser reveals numerous sites where this username appears. Make sure WP and plugins are up to date.

User Last Login Sort Column

I don’t see anywhere in your code that the query is being modified. Just flagging a column to be sortable doesn’t mean it knows how to sort the data – it will just add the little up/down arrow and make the column clickable but you have to intercept the query var accordingly and tell WP … Read more

UberMenu list current user’s posts as menu items

the_permalink(), the_title() by default echo their value. As you want to store that value in a variable you will need to return the values instead. get_the_permalink(), get_the_title() are two similar functions that return the value instead of echo. So you new code may look something like this: $list=”<li class=”ubermenu-submenu ubermenu-submenu-id-122-col-0 ubermenu-submenu-type-stack”>”; $list .= ‘<a class=”ubermenu-target … Read more

How to run a mysql query when admin updates user role?

You are going in wrong direction there is no way to get user role while admin change from back end. You can retrieve the role object for the current user by calling get_role(), but that’s an object rather than a string with the role name. function get_user_role($uid) { global $wpdb; $role = $wpdb->get_var(“SELECT meta_value FROM … Read more