Multisite – maximum number of users with specific role

Ok here is how I did it: add_action( ‘editable_roles’ , ‘hide_editable_roles’ ); function hide_editable_roles( $roles ){ $blog_id = get_current_blog_id(); // Get current subsite id switch($blog_id) { // Define different max agents numbers depending on subsite id case 6: $max_agents = 10; //for subsite id#6 we can have maximum 10 agents break; case 7: //for subsite … Read more

WordPress custom post type capabilities issue

You definitely need to set map_meta_cap to true instead of false to create custom capabilities. I haven’t seen the ‘capability_type’ => [‘note’,’notes’] way of creating capabilities before – maybe it’s shorthand, but if just changing map_meta_cap doesn’t work, you might want to spell everything out the long way: <?php $args = array( ‘labels’ => $labels, … Read more

How to set default post editor based on role?

create_function() is deprecated as of PHP 7.2.0, so you should avoid using it. Instead, use an anonymous function. Additionally, it’s better the check the current user role inside the callback function, so that the current user role is checked when the filter is applied, not when the hook is added, which could be before the … Read more

Add user role to generated plugin

If you look at the documentation for add_menu_page(), you’ll see the third argument is: The capability required for this menu to be displayed to the user. In WordPress you don’t require specific roles for permissions, you require a capability, and roles are collections of capabilities. Your menu page requires manage_options, which is only held by … Read more

Force modified contributor role to be re-approved on edit?

you can use ‘wp_insert_post_data’ hook to check if the user is not an admin, and if the post status is allready “published” change it to “pending”: add_filter(‘wp_insert_post_data’,’re_aprove’); function re_aprove($data , $postarr){ global $current_user; get_currentuserinfo(); //check if current user is not admin if (!current_user_can(‘manage_options’)){ if ($data[‘post_status’] = “publish”){ $data[‘post_status’] = “pending”; } } return $data; }

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