Proper use of option_page_capability_{$page_name}

So in this hook is not exactly looking for the {$page_name}. Once I replaced the {$page_name} part of this filter to the {$option_group} parameter from my register_settings() function, all is well in the land of WordPress. Here is what my update needed to look like. function bf_ins_capability(){ return ‘edit_posts’; } add_filter( ‘option_page_capability_bf_insurance_settings’, ‘bf_ins_capability’);

Allow contributor to view own scheduled post

You can write your query for listing scheduled posts as follow : You can see the details here $the_query = new WP_Query(array( ‘post_status’ => ‘future’, ‘posts_per_page’ => 3, ‘orderby’ => ‘date’, ‘order’ => ‘ASC’ )); To show the scheduled post on details page you should do something like this Add code to your theme’s functions.php … Read more

Why is wp-login redirecting to the home page when I use this function?

So, first off, if you want to block access to wp-admin, why hook into something that fires on every page load? Hook into admin_init instead. And, as @MattSmath mentioned, edit isn’t a capability. edit_posts is. Also, admin_init only fires on admin pages, so you can remove is_admin() from your check. Your revised function: <?php add_action(‘admin_init’, … Read more

How do I code access to the built-in UI of a CPT when it’s placed as submenu of another CPT that is protected by role?

From the codex The function which is hooked in to handle the output of the page must check that the user has the required ‘capability’ as well. What it fails to mention is that the check for subpages iterates upwards to its parent. If a user is not capable of accessing TEACHERS, it will not … Read more

How to change in customizer the “site identity” tab required capabilities

This is how I’ve interpreted from the wordpress docs at least. Originally these settings were made with add_setting and it is where the capability was originally set. Fortunately, we can use get_setting to change that value. It seems to work very well for your case. function wpseo_206907_add_back_customizer_controls_for_not_admins( $wp_customize ) { $wp_customize->get_setting( ‘blogname’ )->capability = ‘edit_theme_options’; … Read more

Odd behaviour with submenu link creation

On the same page in codex you have this : NOTE: If you’re running into the “You do not have sufficient permissions to access this page.” message in a wp_die() screen, then you’ve hooked too early. So it answers to you question partly. The second part, the following code should work : add_action(‘admin_menu’, ‘my_add_submenu’); function … Read more

add_cap only adding the first two in array

Looking at your code I think you are trying to modify the capabilities of existent roles. Am I right? To do that you have to run the add_cap for a role object, not for a user object. Also, you must know that add_cap only accept one capability as string: $role = get_role( ‘editor’ ); $role->add_cap( … Read more

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