Restrict Access to the User Profile
Use the function current_user_can( $capability ). Where $capabilty applies. For example: If ( current_user_can( ‘update_plugins’ ){ //do some update plugin stuff }
Use the function current_user_can( $capability ). Where $capabilty applies. For example: If ( current_user_can( ‘update_plugins’ ){ //do some update plugin stuff }
I would always go for the role “check”. As in your case: if ( current_user_can( ‘vendor’ ) ) { // do stuff } Or of course the distributor role as created by you. This way you can be sure that one is not interfering with the other and you can assign each role to its … Read more
You can use add_role function : add_role( $role, $display_name, $capabilities ); Just set your custom values as you wish : add_role(‘basic_contributor’, ‘Basic Contributor’, array( ‘read’ => true, // True allows that capability ‘edit_posts’ => true, ‘delete_posts’ => false, // Use false to explicitly deny )); Plugin : https://wordpress.org/plugins/user-role-editor/
Access level seems to have gone from admin to editor
Please note that translate_user_role doesn’t work in the front-end currently. Here is a workaround, you can place this in your theme: add_action( ‘init’, ‘load_admin_textdomain_in_front’ ) function load_admin_textdomain_in_front() { if ( ! is_admin() ) { load_textdomain( ‘default’, WP_LANG_DIR . ‘/admin-‘ . get_locale() . ‘.mo’ ); } }
How to bulk change user role to “No role for this site”
To fetch users from a specific role, you can use the role parameter of the get_users function. Each role has a specific ID; for WordPress’ native roles, these are administrator, editor, author, contributor and subscriber. In your case, you would want to fetch only subscriber users: $allUsers = get_users( array( ‘orderby’ => ‘post_count’, ‘order’ => … Read more
In the similar scenario, I had used Capability Manager Enhanced to customize capabilities. It will allow you to change capabilities of any role without diving into codes. Please take a look.
You can use wp_dropdown_roles()
The Role Scoper plugin can enable this.