Custom User Roles

VIP Go platform specific

This document is for sites running on VIP Go.

Learn more

Sometimes the default roles and capabilities aren’t exactly what you need for your site. If you need to create new roles or modify existing ones, we have helper functions to assist you in doing this. Please use these functions rather than the traditional methods as this will ensure that your code works on WordPress.com and in your development environments.

As an example, here’s how you can register a “Reviewer” role:

add_action( 'init', function() {
    wpcom_vip_add_role( 'reviewer', 'Reviewer', array(
        'read' => true,
        'edit_posts' => true,
        'edit_others_posts' => true,
        'edit_private_posts' => true,
        'edit_published_posts' => true,
        'read_private_posts' => true,
        'edit_pages' => true,
        'edit_others_pages' => true,
        'edit_private_pages' => true,
        'edit_published_pages' => true,
        'read_private_pages' => true,
    ) );
} );

Note: you’ll want to use these helper functions on the ‘init’ hook.

You can find all available capabilities in WordPress Codex.

Here are some more examples:

add_action( 'init', function() {
	// Add new role
	wpcom_vip_add_role( 'super-editor', 'Super Editor', array( 'level_0' => true ) );

	// Remove publish_posts cap from authors
	wpcom_vip_merge_role_caps( 'author', array( 'publish_posts' => false ) );

	// Remove all caps from contributors
	wpcom_vip_override_role_caps( 'contributor', array( 'level_0' => false ) );

	// Duplicate an existing role and modify some caps
	wpcom_vip_duplicate_role( 'administrator', 'station-administrator', 'Station Administrator', array( 'manage_categories' => false ) );

	// Add custom cap to a role
	wpcom_vip_add_role_caps( 'administrator', array( 'my-custom-cap' ) );

	// Remove cap from a role
	wpcom_vip_remove_role_caps( 'author', array( 'publish_posts' ) );
} );

Ready to get started?

Drop us a note.

No matter where you are in the planning process, we’re happy to help, and we’re actual humans here on the other side of the form. 👋 We’re here to discuss your challenges and plans, evaluate your existing resources or a potential partner, or even make some initial recommendations. And, of course, we’re here to help any time you’re in the market for some robust WordPress awesomeness.