Okay
  Public Ticket #858320
Maintenance mode
Closed

Comments

  • Marius started the conversation

    Hi guys,

    This is not quite an issue ticket, but more an inquiry. I would like to know if it's possible and if it is, how can I add some other roles for the Maintenance mode? I would like on my site, when the maintenance mode is on, the authors to be able to see the website as well, so the maintenance page will be displayed only for the visitors. 

    I've looked through functions.php and extras.php, but I'm not sure where I can edit the function "$except_admin" to add also the author role. 

    Thank you very much!

    Kind regards,
    Marius

  •  522
    Nikita replied

    Hi, Marius.

    See here how to check if current user is author - http://wordpress.stackexchange.com/questions/5047/how-to-check-if-a-user-is-in-a-specific-role

    So, to show website for authors you should extend condition in function youplay_is_maintenance in extras.php file. For now it checked for admins only:

    if( ... (is_admin() || is_super_admin()) ) {
        ...
    }
    

    Best regards, nK.

  • Marius replied

    Hi Nikita,

    I've tried the following code in the extras.php, but apparently, it simply doesn't work. It doesn't recognize my author role. 


    if (is_author()) { 
    $maintenance = false;
    } else {
    if($maintenance && $except_admin && (is_admin() || is_super_admin())) {
    $maintenance = false;
    }
    }

    Please let me know your thoughts. Many thanks!

    Kind regards,
    Marius

  •  522
    Nikita replied

    Example:

    $user = wp_get_current_user();
    $is_author = in_array( 'author', (array) $user->roles );
    if($maintenance && $except_admin && ($is_author || is_admin() || is_super_admin())) {
        $maintenance = false;
    }
    
  • Marius replied

    Hi Nikita, 

    Perfect!!! Love you big time. Many thanks!

    Kind regards,
    Marius