Change capability type of post type registered by plugin

I’m using the plugin Custom CSS JS which registers it’s own post type but the capability is assigned to “post”. I want to change it to “manage_options”. Is there a correct way without altering the plugin to do that? Calling a hook, a function or whatever? public function register_post_type() { $labels = array ( ‘name’ … Read more

How can I grant capabilities directly to users (not roles) in wp-admin?

I want to create dynamic capabilities using WP_Role::add_cap(), something like $author_role = get_role(‘author’); foreach ($sections as $section) { $author_role->add_cap( “edit_{$section}_pages”, /* grant= */ false ); } and then let administrators grant certain of those capabilities to certain authors only (e.g., Jane can edit_school_pages) in wp-admin (not programmatically, via WP_User::add_cap()). I assume a plugin can help … Read more

add_menu_page permissions – what am I doing wrong?

I am running a fresh install of WordPress 3.3.2 and the only plugin enabled is one I’m developing, but I can’t seem to get past a permissions issue in add_menu_page. With the exception of using anonymous functions instead of named functions, I’m following the documentation almost exactly. My plugin source: <?php /* Plugin Name: Some … Read more

How to assign specific users the capability to edit specific pages / posts / custom post types

I’m trying to implement what seemed like a relatively straight forward idea, basically I am building an access control plugin to control viewing and editing of a custom post type (in this case ‘Projects’). How I intend for it to work is that there are multiple users who either have read-only access or read/write access … Read more

Add Custom User Capabilities Before or After the Custom User Role has Been Added?

Should custom user capabilities be added before the custom user role has been added, or the other way around? add_role() asks for and array of $capabilities in the third parameter of the function. add_cap() asks for a $role to apply the capability to in the first parameter of the function. Both add_role() and add_cap() need … Read more

Capabilities Vs User Meta

What is the advantage of using capabilities instead of usermeta? For example a cap access_feature_x vs meta access_feature_x. I can use current_user_can() vs get_user_meta() on various checks. So, what improvement does capabilities provides? Edit The question seem too broad for a specific answer. So, I will provide an example context. Please keep your original answers … Read more

Disallowing Users of a Custom Role from Deleting or Adding Administrators?

(Moderator’s note: The original title was “Custom User Role Restrictions”) A project I am working on requires me to create two new user roles – one for the owner of the website and the other for agents of the company. With the website owner user role I was just looking for a way to restrict … Read more

How to let contributors to create a new revision(draft) editing their published posts

I’m using a custom post type to let contributors have a personal page on the site. Any time a user registers on my site a script creates a custom type post that has the registering user as the author. To moderate users’ entries this post is published by an editor. I would like users (contributors) … Read more