How to copy user_nicename value into user_login
Run the following SQL query in PHPMyAdmin or similar. UPDATE wp_users SET user_login = user_nicename; wp_users is the table for users (make sure it matches yours)
Run the following SQL query in PHPMyAdmin or similar. UPDATE wp_users SET user_login = user_nicename; wp_users is the table for users (make sure it matches yours)
You’re looking for profile_update & user_register. user_register is called after a user is created. add_action( ‘user_register’, ‘myplugin_registration_save’, 10, 1 ); function myplugin_registration_save( $user_id ) { // Do stuff with $user_id } profile_update is called after a user is updated. add_action( ‘profile_update’, ‘my_profile_update’, 10, 2 ); function my_profile_update( $user_id, $old_user_data ) { // Do stuff with … Read more
Replace the prefix in wp_users and wp_usermeta table names for the one you use. Make backup of data from both tables before you start to delete users. DELETE u FROM wp_users u LEFT JOIN wp_usermeta um1 ON u.id = um1.user_id AND um1.meta_key = ‘first_name’ LEFT JOIN wp_usermeta um2 ON u.id = um2.user_id AND um2.meta_key = … Read more
Ok here is how I did it: add_action( ‘editable_roles’ , ‘hide_editable_roles’ ); function hide_editable_roles( $roles ){ $blog_id = get_current_blog_id(); // Get current subsite id switch($blog_id) { // Define different max agents numbers depending on subsite id case 6: $max_agents = 10; //for subsite id#6 we can have maximum 10 agents break; case 7: //for subsite … Read more
You don’t give them IDs. The user ID column in the database is an ‘auto increment’ column, meaning that the value is automatically created whenever a row is added. So just add your users without an ID and the database will create one for you.
Yes, WordPress checks for duplicate emails internally, but not duplicate usernames To test this I ran this several times via wp shell: wp_create_user( ‘test’, ‘password’, ‘[email protected]’ ); The result on the second attempt was: => class WP_Error#1962 (2) { public $errors => array(1) { ‘existing_user_email’ => array(1) { [0] => string(42) “Sorry, that email address … Read more
Use this hook function to replace user’s avatar (which is passed in as HTML <img …> tag) if user’s ID or email matches your condition. You can use any other default image, or get individual replacement image for each user. function my_get_avatar($avatar, $id_or_email, $size, $default, $alt) { if ($id_or_email == “[email protected]”) { $img = “http://path.to/default/avatar.jpg”; … Read more
You do not want an OR, you want an AND. Follow it through and substitute the values. If we are user 1, then it’s true because we are not user 2, and true OR false resolves to true. Only one of them needs to be true for an OR to be true. If we are … Read more
If you just want to write a single <option> for the current user, you can get the user object from wp_get_current_user() – you don’t need a WP_User_Query at all: function getСurrentUserForFilter() { if ( is_user_logged_in() ) { $user = wp_get_current_user(); echo ‘<option value=”‘.$user->ID.'”>’.esc_html($user->user_email).'</option>’; } }
It’s failing because WordPress isn’t loaded. Instead of making AJAX requests directly to PHP files in your theme, make them to a REST API endpoint. For example: add_action( ‘rest_api_init’, function () { register_rest_route( ‘petebolduc/v1’, ‘/test/’, array( ‘callback’ => ‘petebolduc_ajax’ ) ); } ); function petebolduc( $parameters ) { $foo = $parameters[‘foo’]; return “foo is ” … Read more