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

Get Current User info using wp_localize_script, in functions.php

If you read about this action here. You will see that this hook provides access to two parameters, $user->user_login (string) and $user ( WP_User ). Using it like this you will see all the info you have access to: function add_to_login($user_login, $user) { echo “<pre>”.print_r($user, true).”</pre>”; } add_action(‘wp_login’, ‘add_to_login’, 10, 2); But after a little … Read more

Is there any way to allow users to access content before it’s published?

You can use this in a template file: $tomr = getdate(time()+86400); //utc=gmt time in seconds, add 24 hours = 86400 seconds $args = array( ‘post_status’ => ‘future’, ‘date_query’ => array( array( ‘year’ => $tomr[‘year’], ‘month’ => $tomr[‘mon’], ‘day’ => $tomr[‘mday’], ‘column’ => ‘post_date_gmt’ //since we are using the gmt timestamp ), ), ); $query = … Read more

Creating user relationships

WordPress does provide you with the ability to save meta data for users, so you could just store the agent’s user id in a meta field of his subscribers, like update_user_meta( $user_id, “agent”, $agent_id ). You can then query those users with the WP_User_Query’s meta_query, e.g. $agents_subscribers = new WP_User_Query( array( ‘meta_key’ => ‘agent’, ‘meta_value’ … Read more

Does WordPress always create unique passwords?

Theoretically No! But practically Yes! Every new framework/CMS now implements some sort of library that adds randomness to the actual password. Its a randomly generated salt in form of a random string or time, etc. That is saved along with the hash password in database. Since theoretically, a collision can occur in any cryptographic function … Read more