• Resolved richmud

    (@richmud)


    Hello,

    I’m trying to add a new user role to my WordPress multisite installation that can manager users for one particular site.

    My add_role function looks like this –

    $result = add_role( 'production_editor', __(
    	'Production Editor' ),
    	array(
    		'read' => true,
    		'list_users' => true,
    		'remove_users' => true,
    		'edit_users' => true,
    		'create_users' => true,
    		'delete_users' => true,
    		'promote_users' => true,
    		'manage_network_users' => true,
    	)
    );

    This is working fine to list/edit users, but I can only add existing users, and I need to be able to add completely new users that don’t already exist (as super admins are able to do).

    What updates/capabilities would this require on the role?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    The role and capabilities are fine. By default only super admins can add new users. It is enforced by role, not capability, so there is no work around with capabilities.

    However, you can override this behavior on a per site basis 🙂 Set the site’s option “add_new_users” to 1 (true) in the sitemeta table. You can use update_site_option() to do this.

    FYI, this is enforced in map_meta_cap().

    Thread Starter richmud

    (@richmud)

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Custom User Role – ‘add_user’ Capabilities (Multisite)’ is closed to new replies.