Generate unique number when registering a new user

This way would work … the user_register action is fired when the user is stored in the data base. You can add meta data to a user with add_metadata. add_action( ‘user_register’, ‘myplugin_registration_save’, 10, 1 ); function myplugin_registration_save( $user_id ) { add_metadata( $user_id, ‘unique_number’, date( ‘Y’ ).str_pad( $user_id, 4 ) ); }

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

Add user data to table when user is created?

Looks to me you should be seeking a woocommerce purchase completion hook. This would be when you could add that a donation has been made and at what amount, then you could grab any user information, amounted donated and other info you need and save it to your donor table. use this: add_action(‘woocommerce_order_status_completed’, ‘save_to_donors’,10,1); instead … Read more

Order users by last word of last name

This should do it: usort($users, ‘wpse_235438_sort_users’ ); function wpse_235438_sort_users( $a, $b ) { $a_last_name = array_pop( explode( ‘ ‘, $a->last_name ) ); $b_last_name = array_pop( explode( ‘ ‘, $b->last_name ) ); return strnatcasecmp( $a_last_name, $b_last_name ); } explode() will convert your names into arrays; array_pop() will give you the last item in those arrays, which … Read more