I would like new users of the blog to have custom role, rather then Subscriber. How do I set this programmatically? I know that it can be changed from the backend.
This allows plugins to easily hijack the default role while they're active.
I use it to make sure some plugins that need subscriber roles get it regardless of Administrator attempts to change :)
When a new user is created through the
The default user role is retrieved from the database
If you've registered your new role (using
Alternatively, for more control you can hook into the
After you created the user using
$user_id = wp_create_user( $user_login, $pas1, $user_email );
Create the user object
$user = new WP_User($user_id);
Then set the role
You can replace the 'editor' role with any of the following: Administrator,Editor,Author,Contributor,Subscriber