php – I have. a snippet to redirect all user to a maintenance page. But I want exclude users in admin role

Question

So I have a snippet that redirects all user to a maintenance page. How can I tweak it to All users except admin users? Thanks

<?php

add_action( 'template_redirect', function() {
    if ( is_page( 4848 ) ) {
        return;
    }
    wp_redirect( esc_url_raw( home_url( 'maintenance/' ) ) );
    //wp_redirect( esc_url_raw( home_url( 'index.php?page_id=4848' ) ) );
    exit;
} );

0
Blue Li 1 year 2022-01-01T01:47:52-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse