public function restrictAdminBarVisibility()
    {
        // Don't go further if not logged in or within admin panel
        if (is_admin() || !is_user_logged_in())
        {
            return;
        }

        $data = $this->getData();

        // Don't go further if no setting
        if ( !isset($data['admin_bar']) || empty($data['admin_bar']))
        {
            return;
        }

        $access = $data['admin_bar'];

        // Is current user's role within our access roles?
        $user = wp_get_current_user();
        $role = $user->roles;
        $role = (count($role) > 0) ? $role[0] : '';
        $isUserIncluded = in_array($role, $access['roles']);

        // Hide admin bar if required
        if (($access['mode'] == 'show' && !$isUserIncluded)
            || ($access['mode'] == 'hide' && $isUserIncluded)
        )
        {
            show_admin_bar(false);
        }
    }
public function restrictAdminBarVisibility()
    {
        // Don't go further if not logged in or within admin panel
        if (is_admin() || !is_user_logged_in())
        {
            return;
        }

        $data = $this->getData();

        // Don't go further if no setting
        if ( !isset($data['admin_bar']) || empty($data['admin_bar']))
        {
            return;
        }

        $access = $data['admin_bar'];

        // Is current user's role within our access roles?
        $user = wp_get_current_user();
        $role = $user->roles;
        $role = (count($role) > 0) ? $role[0] : '';
        $isUserIncluded = in_array($role, $access['roles']);

        // Hide admin bar if required
        if (($access['mode'] == 'show' && !$isUserIncluded)
            || ($access['mode'] == 'hide' && $isUserIncluded)
        )
        {
            show_admin_bar(false);
        }
    }
public function restrictAdminBarVisibility ( ) { // Don't go further if not logged in or within admin panel if ( is_admin ( ) || ! is_user_logged_in ( ) ) { return ; } $ data = $ this -> getData ( ) ; // Don't go further if no setting if ( ! isset ( $ data [ 'admin_bar' ] ) || empty ( $ data [ 'admin_bar' ] ) ) { return ; } $ access = $ data [ 'admin_bar' ] ; // Is current user's role within our access roles? $ user = wp_get_current_user ( ) ; $ role = $ user -> roles ; $ role = ( count ( $ role ) > 0 ) ? $ role [ 0 ] : '' ; $ isUserIncluded = in_array ( $ role , $ access [ 'roles' ] ) ; // Hide admin bar if required if ( ( $ access [ 'mode' ] == 'show' && ! $ isUserIncluded ) || ( $ access [ 'mode' ] == 'hide' && $ isUserIncluded ) ) { show_admin_bar ( false ) ; } }
Restrict visiblity of the admin bar
Restrict visiblity of the admin bar