Editor role cannot save custom theme options

There’s a bug(ish) report regarding this here: http://make.wordpress.org/themes/2011/07/01/wordpress-3-2-fixing-the-edit_theme_optionsmanage_options-bug/ You can use a filter to modify the theme page capability. First you’ll want to edit your register_setting() calls to look like this: register_setting( ‘map-options’, ‘map_zoom’ ); register_setting( ‘map-options’, ‘map_longitude’ ); register_setting( ‘map-options’, ‘map_latitude’ ); The first parameter is the settings group and this is what we’re … Read more

current_user_can( ‘edit_post’, $post_id ) does not work for contributer but for administrator

using map_meta_cap I added edit_post per post cap to user function my_map_meta_cap( $caps, $cap, $user_id, $args ){ if ( ‘edit_post’ == $cap ) { $post = get_post( $args[0] ); $post_type = get_post_type_object( $post->post_type ); $caps = array(); if ( $user_id == $post->post_author ) $caps[] = $post_type->cap->edit_posts; else $caps[] = $post_type->cap->edit_others_posts; } return $caps; } add_filter( … Read more

Create user role restricted to specific CPT

You need to register the CPT with your custom capability, then assign that specific cap to the user. When passing the arguments to register_post_type, set capability_type to your new capability, so the check turns into ‘edit_cpts’ instead of ‘edit_post’. By setting ‘capability_type’ => [ ‘cpt’, ‘cpts’ ], ‘cpt’ will map to ‘post’ for standard capability … Read more

Do custom user roles have any default capabilities?

I’ve found that the WordPress has_cap() function, which is relied on by functions like user_can() and current_user_can, explicitly returns false for empty capabilities. Example: If a capability is passed as an argument using current_user_can(), this function will pass the capability to has_cap() and return the results: return call_user_func_array( array( $current_user, ‘has_cap’ ), $args has_cap() will … Read more

Allowing Custom Capability to Manage Plugin Options

If you use the Settings API, that $option_page is the value of a hidden <input> field generated by settings_fields(). For example: <input type=”hidden” name=”option_page” value=”{Option group name}”> So if you have settings_fields( ‘my-group’ ) in your code, then the $option_page would be my-group. See the (as of writing, 5th) note here. Code sample: (tried and … Read more

Capability to edit own posts and not others

The capabilities that you are trying to restrict are delete_others_posts edit_others_posts Apart from Super Admin and Administrator, the only Role that have these permission is Editor. So, removing these capabilities from Editor should accomplish this. /** * Remove capabilities from editors. * * Call the function when your plugin/theme is activated. */ function wpcodex_set_capabilities() { … Read more

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