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.

4

This allows plugins to easily hijack the default role while they’re active.

// Hijack the option, the role will follow!
add_filter('pre_option_default_role', function($default_role){
    // You can also add conditional tags here and return whatever
    return 'subscriber'; // This is changed
    return $default_role; // This allows default
});

I use it to make sure some plugins that need subscriber roles get it regardless of Administrator attempts to change 🙂

Regards.

Leave a Reply

Your email address will not be published. Required fields are marked *