Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Removing the admin bar and backend from normal users like here on CSS Tricks

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #167728
    WMEric
    Participant

    Hello Everyone,

    I was wondering how does CSS Tricks completely hide the whole backend and dashboard so well?

    Thanks

    #167734
    Senff
    Participant

    What do you mean by “hide the backend” exactly?

    #167735
    WMEric
    Participant

    Sorry, I mean like hiding the dashboard from logged in users and such.

    I pretty much have a general idea using:

    methods like current_user_can(‘role here’)

    I don’t think there’s a good reason to have a user looking at the dashboard.

    Thanks for the reply :)

    #167736
    Alen
    Participant

    Add add_filter( 'show_admin_bar', '__return_false' ); to your functions.php file.

    #168403
    gilgimech
    Participant

    You can use this

    add_action( 'init', 'blockusers_init' );
    
    function blockusers_init() {
        if ( is_admin() && ! current_user_can( 'administrator' ) && 
           ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
            wp_redirect( home_url() );
            exit;
        }
        if( ! current_user_can( 'administrator' ) ) {
            add_filter( 'show_admin_bar', '__return_false' );
        }
    }
    
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.