WordPress.org

Ready to get started?Download WordPress

Forums

Add a role (3 posts)

  1. Franz Josef Kaiser
    Member
    Posted 3 years ago #

    Hi,

    i'm trying to add a role of "developer". This role should contain all capabilities of the admin-role ($allcaps) plus a developer role. Currently my only problem are the "allcaps"-capabilities. I simply don't know how i can receive them when adding a role.

    >> Role:
    global $allcaps;
    $role = "developer";
    $display_name = "Developer";
    $allcaps = "????????????";
    add_role( "developer", "Developer", $allcaps )
    >> Capability:
    $role = get_role('developer');
    if ($role !== NULL) {
     $role->add_cap('dev_cap');
    }

    I need this in themes where i got other admins too, that should not see any changes i make on templates, so can use something like this:

    if(current_user_can('developer')) {
     code i work on
    } else {
     old code - or - maintainance message
    }
  2. Franz Josef Kaiser
    Member
    Posted 3 years ago #

    As far, as i can see, it's only possible to paste them bit by bit as an array. The following sollution works for 2.9.2 ... but what if there are new capabilities?

    $role = get_role('developer');
        if ($role !== NULL) {		$role->add_cap('developer');		$role->add_cap('administrator');		$role->add_cap('activate_plugins');		$role->add_cap('create_users');		$role->add_cap('delete_others_pages');		$role->add_cap('delete_others_posts');		$role->add_cap('delete_pages');		$role->add_cap('delete_plugins');		$role->add_cap('delete_posts');		$role->add_cap('delete_private_pages');		$role->add_cap('delete_private_posts'); $role->add_cap('delete_published_pages');		$role->add_cap('delete_published_posts');		$role->add_cap('delete_users');		$role->add_cap('edit_dashboard');		$role->add_cap('edit_files');		$role->add_cap('edit_others_pages');		$role->add_cap('edit_others_posts');		$role->add_cap('edit_pages');		$role->add_cap('edit_plugins');		$role->add_cap('edit_posts');		$role->add_cap('edit_private_pages');		$role->add_cap('edit_private_posts');		$role->add_cap('edit_published_pages');		$role->add_cap('edit_published_posts');		$role->add_cap('edit_themes');		$role->add_cap('edit_users');		$role->add_cap('import');		$role->add_cap('install_plugins');		$role->add_cap('install_themes');		$role->add_cap('level_0');		$role->add_cap('level_1');		$role->add_cap('level_2');		$role->add_cap('level_3');		$role->add_cap('level_4');		$role->add_cap('level_5');		$role->add_cap('level_6');		$role->add_cap('level_7');		$role->add_cap('level_8');		$role->add_cap('level_9');		$role->add_cap('level_10');		$role->add_cap('manage_capabilities');		$role->add_cap('manage_categories');		$role->add_cap('manage_links');		$role->add_cap('manage_options');		$role->add_cap('moderate_comments');		$role->add_cap('publish_pages');		$role->add_cap('publish_posts');		$role->add_cap('read');		$role->add_cap('read_private_pages');		$role->add_cap('read_private_posts');		$role->add_cap('switch_themes');		$role->add_cap('unfiltered_html');		$role->add_cap('unfiltered_upload');		$role->add_cap('update_plugins');		$role->add_cap('update_themes');	$role->add_cap('upload_files'); $role->add_cap('dev_cap');
    	}
  3. Franz Josef Kaiser
    Member
    Posted 3 years ago #

    push

Topic Closed

This topic has been closed to new replies.

About this Topic