function to assign user role based on a field from usermeta
function to assign user role based on a field from usermeta
function to assign user role based on a field from usermeta
My solution would be this: function get_all_user_data($user_id) { $user_data = get_userdata($user_id); $login = $user_data->user_login; $customer_array = new WC_Customer( $user_id ); $customer = $customer_array->get_data(); $billing_first_name = $customer[billing][first_name]; $shipping_first_name = $customer[shipping][first_name]; } add_action(‘user_register’,’get_all_user_data’); add_action(‘profile_update’,’get_all_user_data’); The array setup for the Customer arrays [billing] and [shipping] is as so (you can just change my values and get different data … Read more
That error messages means a failed admin nonce validation (check_admin_referer, which calls wp_nonce_ays). And you don’t actually need an extra nonce here: these are extra fields to be added to existing forms that already have their own nonces, and the one you’ve added just clashes with them. (If you were adding a new form you … Read more
<?php $id = get_current_user_id(); // this is for the current user, for other user just change this variable to the user id intended $link = get_user_meta( $id, ‘avatar’, true ); ?> <img src=”<?php echo $link ?>” alt=””> That is your answer, but if you want to understand it just continue reading!.. (only after writing everything … Read more
You can’t do this in a query with that kind of data. The only way to truly do it is to retrieve all users, and manually process them in PHP to find the ID. Otherwise, you will get false positives such as the example you gave. The fundamental problem, is the way the data is … Read more
Here is an approach you could take to do this. It’s problematic if you have a large number of users, but it could be adapted in-time. do { // 1. generate your unique random number $result = rand(); // 2. check it is really unique $is_unique = count( get_users( array( ‘meta_key’ => ‘user_reference_id’, ‘meta_value’ => … Read more
How to replicate a user plugin made table value, to this user’s custom meta table value?
How to properly add a custom submenu to the user’s admin menu
Is it safe to delete unnecessary user metadata?
How to redirect on login to a specific page if a specific meta user is empty