0

I'm working on a Wordpress website having this bug : 9000 users should be "subscriber" (Wordpress role), but they have no role assigned now (probably due to a users import script) :

Image : https://i.stack.imgur.com/PLKpW.jpg

In the meta_value, we can see their name instead of the role : Dupont, Maurice ... How can I assign the role/capability "subscriber" to all users without role ?

I found a plugin doing this in bulk but it cannot handle more than 1000-2000 users and the link for download is broken.

Many thanks in advance

user2326202
  • 1
  • 1
  • 2

1 Answers1

1

You can do this with a single query. Please check before running that a:1:{s:13:"administrator";b:1;} is the only value than need to be preservered. If there is others, add them in the query conditions.

UPDATE wp_usermeta
    SET meta_value = 'a:1:{s:10:"subscriber";b:1;}'
WHERE
    meta_key = 'wp_capabilities' AND
    meta_value != 'a:1:{s:13:"administrator";b:1;}'
vard
  • 4,057
  • 2
  • 26
  • 46