Mass update user roles using wp cli

Change all users with a role of “subscriber” to “pmpro_role_2”

for USER_ID in $(wp user list --role=subscriber --field=ID); do wp user update $USER_ID --role=pmpro_role_2; done

List number of users for each role

wp eval 'print_r( count_users() );' 

wp cli

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk