Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results for do_not_allow map_meta_cap
Search options not deleted
0 votes
1 answer
289 views

Custom map_meta_cap filter does not return ['do_not_allow']

I have used map_meta_cap filter to solve this. … However even though it goes through my function correctly it will not function properly, return ['do_not_allow']; is not working as intended and I don't know why, it seemingly does not do anything. …
Ulvar's user avatar
  • 3
2 votes
Accepted

current_user_can() always returns true if user is super admin

The only way to explicitly deny a capability for a super admin is to use the map_meta_cap filter to return do_not_allow when the custom capability is checked. … Because map_meta_cap() is run before the super admin check, we can use this filter to explicitly return do_not_allow when checks for current_user_can( 'custom_capability' ) are made for a super admin that …
Jacob Peattie's user avatar
1 vote
Accepted

How to disable delete option for a specific page?

The map_meta_cap filter allows us change this mapping. So we'll use it to map delete_post to do_not_allow for this specific post. Then no users will be able to delete that post. … '; } return $caps; } add_filter( 'map_meta_cap', 'wpse_312694_restrict_page_deletion', 10, 4 ); …
Jacob Peattie's user avatar
6 votes

Allow user to Edit Posts but not Add New?

Instead, when registering your custom post type, you need to set the create_posts value to do_not_allow (or false in Wordpress versions below 4.5) and crucially set the map_meta_cap to true. … ), 'map_meta_cap' => true, // With this set to true, users will still be able to edit & delete posts )); If map_meta_cap is left out, it defaults to false and although you've disabled the ability …
indextwo's user avatar
  • 441
1 vote

How Do I Remove Pagination From A Single Blog Entry?

with the Roles and Capabilities system, but broadly, I think it might be fairly directly accomplished by adding a list of Roles to terms' meta-data, then comparing those roles against a user's within a map_meta_cap … filter, producing either the current post's read_post meta capability or the do_not_allow capability to enforce whether or not they can read the post. …
bosco's user avatar
  • 6,954
0 votes

Adding all custom capabilities to admin

users or user roles, including administrators, but if Multisite is enabled, then those who are super admins would always be able to manage (e.g. edit or delete) the posts in the post type, unless if do_not_allow … is present in their capabilities (as returned by map_meta_cap()) — see WP_User::has_cap(). …
Sally CJ's user avatar
  • 39.9k
1 vote

Custom Post Type - after disable 'Add New', I can't edit and delete post

Full credit to this answer on Stack Overflow: you need to set the create_posts value to do_not_allow (or false in Wordpress versions below 4.5) and crucially set the map_meta_cap to true: register_post_type … ( 'custom_post_type_name', array( 'capability_type' => 'post', 'capabilities' => array( 'create_posts' => 'do_not_allow', // Prior to Wordpress 4.5, this was false ), 'map_meta_cap
indextwo's user avatar
  • 441
1 vote
Accepted

Remove theme, change theme button and WP version on "Right Now" admin dashboard?

','disable_caps',10,2); } function turn_on_caps() { remove_filter('ngettext','disable_theme'); remove_filter('map_meta_cap','disable_caps',10,2); } function disable_caps($caps,$cap) { if … ( 'update_core' == $cap ) $caps[] = 'do_not_allow'; if( 'switch_themes' == $cap ) $caps[] = 'do_not_allow'; return $caps; } function disable_theme($text) { if('Theme …
Rarst's user avatar
  • 99.9k
3 votes

Limit the number of plugins that can be installed in a WordPress installation

The most performant way to do this is probably by hooking into map_meta_cap to conditionally disallow the install_plugins capability. There are no database calls involved with that. … if ( count( $plugins ) > 10 ) { $caps[] = 'do_not_allow'; } } return $caps; } I recommend you to watch this video by John Blackbourn to learn more about map_meta_cap and friends. …
swissspidy's user avatar
  • 3,914
2 votes

Prevent posts with certain post_meta to be edited

I think an elegant way to accomplish this would be to hook into map_meta_cap and deny users as though they do not have the capability to edit the post. … == 'edit_post' ) return $caps; $post_id = $args[0]; if( get_post_meta( $post_id, 'global_post', true ) ) $caps[] = 'do_not_allow'; return $caps; } An introduction to roles & capabilities …
bosco's user avatar
  • 6,954
12 votes
Accepted

Prevent trash/delete action on specific post types

Here's another approach using the map_meta_cap filter that's applied within the map_meta_cap() function within the has_cap() method of the WP_User class (PHP 5.4+): add_filter( 'map_meta_cap', function … empty( $args[0] ) ) return $caps; // Target the payment and transaction post types if( in_array( get_post_type( $args[0] ), [ 'payment', 'transaction' ], true ) ) $caps[] = 'do_not_allow
birgire's user avatar
  • 67.8k
-1 votes

How to allow Unfiltered HTML in a wordpress multisite install

The problem is that WordPress has a global override in the method map_meta_cap() in wp-includes/capabilities.php, which ignores the unfiltered_html capability in a multisite install if the user is not … if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML ) { $caps[] = 'do_not_allow'; // } elseif ( is_multisite() && ! …
Brett Donald's user avatar
2 votes
Accepted

Wordpress disable 'Install Themes' tab

You can essentially 'block' the capability install_themes using; function __block_caps( $caps, $cap ) { if ( $cap === 'install_themes' ) $caps[] = 'do_not_allow'; return $caps; } add_filter … ( 'map_meta_cap', '__block_caps', 10, 2 ); …
TheDeadMedic's user avatar
  • 36.6k
1 vote
Accepted

How to hide plugin options for editors via functions.php

function ra_block_tp_edit( $caps, $cap ) { if($cap == 'edit_plugins' ) $caps[] = 'do_not_allow'; return $caps; } add_filter( 'map_meta_cap', 'ra_block_tp_edit', 10, 3 ); Best of luck. …
IFightCode's user avatar
5 votes
Accepted

Custom user role that can only edit specific (non-custom-type) page and all child pages

However, you can filter capabilities checks and change them on the fly using the map_meta_cap. … If they are, set the required capabilities to 'do_not_allow' * to prevent them editing. */ if ( ! …
Jacob Peattie's user avatar

15 30 50 per page