Change WordPress user roles and capabilities › Forums › Give user access to plugin – how to › WordPress Posts Bulk Editor Professional not appearing in dashboard sidebar menu
- This topic has 4 replies, 2 voices, and was last updated 3 years, 8 months ago by Vladimir.
-
AuthorPosts
-
18/03/2021 at 19:18 #7428TWalkerParticipant
I cannot get this plugin (WordPress Posts Bulk Editor Professional) to show for my custom user roles. Neither in the admin bar or in the dashboard sidebar. I have emailed the plugin to support@ – thank you for your help.
19/03/2021 at 01:53 #7430VladimirKeymasterWPBE plugin developer decides that this plugin should be available only to users with ‘administrator’ or ‘editor’ role. Instead of user capability, which you would grant to any custom role, plugin checks directly ‘administrator’ and ‘editor’ role before add its menu page:
if (WPBE_HELPER::can_manage_data()) { add_action('admin_menu', function() { add_menu_page(esc_html('WPBE Bulk Editor', 'bulk-editor'), esc_html('WPBE Bulk Editor', 'bulk-editor'), 'publish_posts', 'wpbe', function() { $this->print_plugin_options(); }, 'dashicons-hammer', 90); }, 99); }
public static function can_manage_data($user_id = 0) { if ($user_id === 0) { $user = wp_get_current_user(); } else { $user = get_userdata($user_id); } // !!! this condition does not allow custom roles to use this plugin if (in_array('administrator', $user->roles) OR in_array('editor', $user->roles)) { return TRUE; } return FALSE; }
19/03/2021 at 02:11 #7431TWalkerParticipantSo are you saying there is no way to get this plugin to work with your plugin? Is there no fix?
19/03/2021 at 02:19 #7432VladimirKeymasterFix is possible, if you are ready to edit this plugin code.
Replace can_manage_data() function at bulk-editor/classes/helper.php file (#356) with the version below. It allows to use plugin to any user who can ‘edit_others_posts’:public static function can_manage_data($user_id = 0) { if ($user_id === 0) { $user = wp_get_current_user(); } else { $user = get_userdata($user_id); } /* if (in_array('administrator', $user->roles) OR in_array('editor', $user->roles)) { return TRUE; } */ if ( current_user_can('edit_others_posts') ) { return TRUE; } return FALSE; }
Take into account that you have to repeat this editing after any plugin update.
19/03/2021 at 02:23 #7433VladimirKeymasterUpdate: as function can accept parameter $user_id, we have to check not current user only, but a user with ID equal $user_id value:
public static function can_manage_data($user_id = 0) { if ($user_id === 0) { $user = wp_get_current_user(); } else { $user = get_userdata($user_id); } /* if (in_array('administrator', $user->roles) OR in_array('editor', $user->roles)) { return TRUE; } */ if ( user_can( $user, 'edit_others_posts') ) { return TRUE; } return FALSE; }
-
AuthorPosts
- You must be logged in to reply to this topic.