How to hide plugin options for editors via functions.php

This should be easiest way, just add the line to wp-config.php, this will disable plugin and theme editor, both. define(‘DISALLOW_FILE_EDIT’,true); If you want to add codes into theme’s function, the code should work for you. 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, … Read more

insufficient permissions; coding an action for plugin governed by custom capability

You should not use the page parameter in an admin url unless you are going to go to an options page because a check for the ‘manage_options’ capability is the default permissions check. The goal of the ‘Delete Cache’ link is to run an action, then redirect to the current page/post; it is not to … Read more

Require Capability to View Woocommerce Product

My guess is that your problem is here: if (is_product_category(‘b2b’)) Taking a look at the Woocommerce Documention for Conditional Tags is_product_category() will return true on product category archives. Therefore, it will never be true on the single product page. What I think you need instead is has_term() which checks a post for a particular term. … Read more

Creating a folder structure

I don’t think what you want is URL rewriting. If I understand correctly, what you want is to restrict access to certain pages, posts, categories, etc., based on the current user’s role or capabilities: “If logged in, do something. If not, do something else (like prompt to login or register).” Modifying the output/behavior of a … Read more

“sufficient permissions” error for admin after duplicating WP database to new install

So you’ve duplicated the tables in the DB, with the new set having the dev_ prefix? In that case, the problem is probably that you have not updated the fields within the duplicated tables that inherit that prefix. For instance, dev_usermeta will now have a meta_key called wp_capabilities. This needs to be dev_capabilities. Also, dev_options … Read more

Completely remove ability to create users?

Okay, so the code above does work, but not for super admins, you must explicitly remove permissions from super admins, like this: // restrict super admin capabilites add_filter(‘map_meta_cap’, ‘restrict_super_admins’, 10, 4); function restrict_super_admins($caps, $cap, $user_id, $args){ $super = array( ‘add_users’, ‘create_users’, ); if( in_array($cap, $super) ) { $caps[] = ‘do_not_allow’; } return $caps; }

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