wp_redirect and current_user_can issues
You should be able to use current_user_can inside the admin_init hooked callback. See the Codex examples.
You should be able to use current_user_can inside the admin_init hooked callback. See the Codex examples.
This is what you need: function my_special_function(){ ?> <div class=”wrap”> <h2>Hello World</h2> <!– ALL THE CUSTOM MARK UP SHOULD BE INSIDE WRAP–> </div> <?php } function my_menu_page(){ add_menu_page(‘Page title’, ‘Menu Title’, ‘administrator’, ‘page_slug’, ‘my_special_function’); } add_action(‘admin_menu’, ‘my_menu_page’); Try this!
You probably cannot see the new CPT items in your menu, because you have indicated that they require specific caps, yet you have not assigned those same caps to any role – including your own. Add the following to your code: function my_cpt_add_caps() { foreach ( array( ‘administrator’ ) as $role_name ) { $role = … Read more
Solved! Meta Capabilities edit_product, delete_product, ‘read_product` etc should be handled separately. Below code is from Justin Tadlocks Site add_filter( ‘map_meta_cap’, ‘fac_map_meta_cap’, 10, 4 ); function fac_map_meta_cap( $caps, $cap, $user_id, $args ) { /* If editing, deleting, or reading a product, get the post and post type object. */ if ( ‘edit_product’ == $cap || ‘delete_product’ … Read more
An author can *edit_posts* but can not *edit_pages*. Personally I prefer in such a case to create a new role which gets the capabilities as needed. A quick shot for a solution of your problem in a custom plugin would be: namespace WPSE\realloc; function activate( $network_wide ) { add_role( ‘division’, __( ‘people in charge of … Read more
I understand that your question is about to establish a default role for a site, such as ‘contributor’ or ‘author’, but also when the site does not exists yet. I found a code snippet that changes the role when the user creates a blog: function user_role_to_new_blog($blog_id, $user_id) { add_user_to_blog($blog_id, $user_id, ‘author’ ); } add_action( ‘wpmu_new_blog’, … Read more
you’re creating a function and just initializing a local scope variable that you overwrite it. here is a different approach: global $wp_roles; // global class wp-includes/capabilities.php $wp_roles->remove_cap( ‘administrator’, ‘manage_options’ ); _based on codex:remove_cap_ Edit: /** * Remove capability from admins. */ function wpcodex_set_capabilities() { // Get the role object. $admin = get_role( ‘administrator’ ); $admin->remove_cap( … Read more
I am pretty sure that nothing would happen other than the user would have the capability in question. Think about it. The default Roles share many capabilities— Authors, Editors, and Administrators all have edit_posts, for example. All roles (usually) have read The same system manages both default and custom roles/capabilities, so there really should be … Read more
I believe your code is right. Try going to: ‘wp-admin/users.php’ manually to check if you have the privilege to do so. If my inkling is right, it’s just the $submenu item that is hidden. If you can access the list of users, try printing the global variable $submenu and see if ‘users.php’ is there.
Visitors have no capabilities. Not even the capability “read” which seems a bit odd to me.