Skip to main content
added 96 characters in body; edited tags
Source Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459

I'm trying to bulk update all my users on one of my Wordpress sites to so that their nicknames aren't the default username but have the format firstname + lastname instead.

I've put together this code and have run it in PhpMyAdmin but it doesn't seem to have changed anything (although I get no errors):

UPDATE wp_users SET user_nicename = CONCAT(
    (
        SELECT meta_value FROM wp_usermeta 
            WHERE meta_key = 'first_name' AND user_id = ID
    ),
    ' ', 
    (
        SELECT meta_value FROM wp_usermeta 
            WHERE meta_key = 'last_name' AND user_id = ID
    ) 
);

Can anyone see where I'm going wrong with this?

Many thanks,

James

I'm trying to bulk update all my users on one of my Wordpress sites to so that their nicknames aren't the default username but have the format firstname + lastname instead.

I've put together this code and have run it in PhpMyAdmin but it doesn't seem to have changed anything (although I get no errors):

UPDATE wp_users SET user_nicename = CONCAT((SELECT meta_value FROM wp_usermeta WHERE meta_key = 'first_name' AND user_id = ID), ' ', (SELECT meta_value FROM wp_usermeta WHERE meta_key = 'last_name' AND user_id = ID));

Can anyone see where I'm going wrong with this?

Many thanks,

James

I'm trying to bulk update all my users on one of my Wordpress sites to so that their nicknames aren't the default username but have the format firstname + lastname instead.

I've put together this code and have run it in PhpMyAdmin but it doesn't seem to have changed anything (although I get no errors):

UPDATE wp_users SET user_nicename = CONCAT(
    (
        SELECT meta_value FROM wp_usermeta 
            WHERE meta_key = 'first_name' AND user_id = ID
    ),
    ' ', 
    (
        SELECT meta_value FROM wp_usermeta 
            WHERE meta_key = 'last_name' AND user_id = ID
    ) 
);

Can anyone see where I'm going wrong with this?

Source Link

SQL Bulk update all Wordpress user's nicknames to firstname + lastname format

I'm trying to bulk update all my users on one of my Wordpress sites to so that their nicknames aren't the default username but have the format firstname + lastname instead.

I've put together this code and have run it in PhpMyAdmin but it doesn't seem to have changed anything (although I get no errors):

UPDATE wp_users SET user_nicename = CONCAT((SELECT meta_value FROM wp_usermeta WHERE meta_key = 'first_name' AND user_id = ID), ' ', (SELECT meta_value FROM wp_usermeta WHERE meta_key = 'last_name' AND user_id = ID));

Can anyone see where I'm going wrong with this?

Many thanks,

James