Add a member number to new user

To get the ID of the user that was created last, you could run the following query: SELECT id FROM wp_users ORDER BY user_registered DESC LIMIT 1 To do this within the context of your code, do this: global $wpdb; $last_user_id = $wpdb->get_results(“SELECT id FROM $wpdb->users ORDER BY user_registered DESC LIMIT 1”); That will give … Read more

update_user_meta doesn’t work with AJAX

First You can get rid of nasty globals in your AJAX call. I’m not sure what the $st variable that you were output is all about so I’ve excluded, but you can include as you wish – add_action(‘wp_ajax_change_subscription’, ‘change_subscription’); function change_subscription(){ if(!empty($_POST[‘term_id’]) && !empty($_POST[‘type’])) : $user_id = get_current_user_id(); update_user_meta( $user_id, ‘hannit_meta’, ‘My Value’ ); endif; … Read more

Delete user from frontend

Taken directly form the wp_delete_user documentation: if(is_user_logged_in() && !empty($_GET[‘DeleteMyAccount’])) { add_action(‘init’, ‘remove_logged_in_user’); } function remove_logged_in_user() { require_once(ABSPATH.’wp-admin/includes/user.php’ ); $current_user = wp_get_current_user(); wp_delete_user( $current_user->ID ); } Things to note: Your code didn’t check if the user was logged in or not by the time you’re printing the remove user link, the init action has already happened … Read more

How To Get User Data in Callback Function for pre_user_nicename?

If anyone should be faced with this problem, check if you have defined a callback function to set the user_login on pre_user_login. This filter is applied inside the wp_insert_user()-function and produced a same username again. Therefore the nicename was changed by adding a “-2”. So, my problem was that I reset the user_logins again and … Read more

What is the meta-box-order_post_hash used for?

I could only find the following core code references for the meta-box-order_ string: /wp-admin/includes/ajax-actions.php: update_user_option($user->ID, “meta-box-order_$page”, $order, true); and /wp-admin/includes/template.php: … get_user_option( “meta-box-order_$page” ) … that’s related to the ordering of meta-boxes. I doubt your $page value is post_hash, so my first guess is that this comes from a plugin/theme? If not then the user … Read more