Custom post type role permissions won’t let me read

Your custom post type looks like it’s set up properly. It works on my test install. Try this instead of whatever add_role and add_cap code you’re currently using. (For testing purposes only. Don’t use it in production code, for reasons outlined below.) It’s working for me: function prefix_set_up_supplier_role(){ remove_role( ‘supplier’ ); add_role( ‘supplier’, ‘Supplier’, array( … Read more

add_role() run only once?

The user roles and capabilities are saved in the database so once you have you have used add_role() its saved and then next load WordPress will know that role just like the built in roles. Now if you look at the function add_role() more specifically at line 141 you will see that it only saves … Read more

Change author base slug for different roles

In your example, the author rewrite pattern changes from /author/[authorname]/ to /[author_level]/[author_name]/. If we allow [author_level] to be anything, we will get into conflict with the rules for pages, because /[anything]/[anything]/ can be either an author archive or a regular subpage. For this reason, my solution assumes you have a limited number of author levels, … Read more

How do I programmatically set default role for new users?

This allows plugins to easily hijack the default role while they’re active. // Hijack the option, the role will follow! add_filter(‘pre_option_default_role’, function($default_role){ // You can also add conditional tags here and return whatever return ‘subscriber’; // This is changed return $default_role; // This allows default }); I use it to make sure some plugins that … Read more

How do I remove dashboard access from specific user roles?

To lock subscribers and contributors out of the admin: function wpse23007_redirect(){ if( is_admin() && !defined(‘DOING_AJAX’) && ( current_user_can(‘subscriber’) || current_user_can(‘contributor’) ) ){ wp_redirect(home_url()); exit; } } add_action(‘init’,’wpse23007_redirect’); Hope that helps. All roles give the user a capability that is the name of that role, so you can use any role name as a capability.

Reset default roles and capabilities

I use User Role Editor. You can delete added roles, and reset roles from the plugin page. To reset the administator role, you can, as of WP 3.4+, add define(‘URE_SHOW_ADMIN_ROLE’, 1); to your wp-config.php file. After having done so, you need to go to Users > User Role Editor and click “Reset”.

How to allow editor to edit privacy page / settings only?

Editing the privacy policy page is restricted to manage_privacy_options as pointed out in a comment in the WordPress core file wp-includes/capabilities.php: /* * Setting the privacy policy page requires `manage_privacy_options`, * so editing it should require that too. */ if ( (int) get_option( ‘wp_page_for_privacy_policy’ ) === $post->ID ) { $caps = array_merge( $caps, map_meta_cap( ‘manage_privacy_options’, … Read more

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