Allow Contributor to edit published post and filter by page id

You can use user_has_cap filter to check and grant capabilities dynamically. add_filter(‘user_has_cap’, ‘contributor_can_edit_published_posts’, 10, 4); function contributor_can_edit_published_posts($allcaps, $caps, $args, $user) { global $post; // Do we have a post? if ( ! $post ) { return $allcaps; } // Is the user a contributor? if ( ! isset( $allcaps[‘contributor’] ) || true !== $allcaps[‘contributor’] ) … Read more

User capability per post

As far as I know, you can not (easily) set up a custom capability for a certain post/page ID. What is described in the Codex, are the so-called meta capabilities (a set of predefined capabilities with additional arguments/information). A (not-that-easy) way is to write your own my_add_cap, my_current_user_can, my_has_cap etc. functions. Regarding your follow-up question… … Read more

Restricted user capabilities cannot add image

You haven’t missed any capabilities. User should be able to insert images into the editor with these capabilities. The only problem I can think of is that, you are trying to modify the capabilities of a role which won’t work. See this section If you are defining a custom role, and adding capabilities to the … Read more

How to show a admin bar menu item only to users with certain capabilities?

The check will be called too early if you just write it in your plugin file like this: if ( current_user_can( ‘add_movies’ ) ) { add_action( ‘admin_bar_menu’, ‘wpse17689_admin_bar_menu’ ); } function wpse17689_admin_bar_menu( &$wp_admin_bar ) { $wp_admin_bar->add_menu( /* … */ ); } Because it will execute when your plugins is loaded, which is very early in … Read more

Filter list of rules based on a capability

Untested, but should be easily extendable(or something you can take ideas from). function roles_have_cap( $roles = false, $cap ) { global $wp_roles; if( !isset( $wp_roles ) || !isset( $cap ) ) return false; if( !$roles ) $roles = array_keys( $wp_roles->roles ); if( !is_array( $roles ) ) $roles = array( $roles ); $hascap = array(); foreach( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)