Dashboard Sidebar for Custom Role

This tip is to make custom role in wplms and then register a custom sidebar for that user role only.

Please follow these steps:

  1. Paste this code in the wplms-customizer.php file present in the wplms customizer plugin OR in the function.php file of your child theme.
function parent_sidebar(){
  $papa_capability=array( 'read');
    add_role( 'parent', __('parent','vibe'), $parent_capability );

  register_sidebar( array(
    'name' => 'Parent Sidebar',
    'id' => 'parent_sidebar',
    'before_widget' => '<div id="%1$s" class="%2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h4 class="dash_widget_title">',
    'after_title' => '</h4>',
        'description'   => __('This is the dashboard sidebar for Parents','wplms-dashboard')
  ) );

This will register a new user role known as parent with the capability to read; and a new sidebar for that user role.

You can change the user role name and its capability according to your requirements.

2) Now paste the following code below the above code.

function wplms_parent_dashboard($sidebar){
    $user = wp_get_current_user();
    if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
        return 'parent_sidebar';
  return $sidebar;


Leave a Reply

Your email address will not be published. Required fields are marked *