• How to change the user_login by the usermeta field of the same User.

    I need to change the WordPress login by the usermeta mat field of all users in a WordPress installation with over a thousand users.

    What’s the best way to do this?

    I Try

    UPDATE wp_users
    SET user_login = (
        SELECT meta_value from wp_usermeta WHERE user_id = ID and meta_key ="_mat"
    )
    WHERE ID = ID;
    

    0 rows affected

    Without success

    SELECT meta_value FROM wp_usermeta as a 
    join wp_users as b ON a.user_id = b.ID 
    WHERE a.user_id = ID and a.meta_key = "_mat"
    Shows several values

    I’m not finding the syntax error

    It is possible using WP_UPDATE_USER( )

     https://developer.www.ads-software.com/reference/functions/wp_update_user/

    Has anyone implemented it yet?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to change the user_login by the usermeta field of the same User.’ is closed to new replies.