Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

wp_ajax_nopriv

add_action( 'admin_init', 'child_limit_backend_to_admin_only' );
/**
 * Redirect logged in user to the home page if they are not an admin
 * 
 * @since 1.0.0
 */
function child_limit_backend_to_admin_only() {

    if ( ! is_admin() ) return;

    // If not the admin, then redirect back to the home page
    if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
        wp_redirect( home_url() ); exit;
    }    

}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
9+7 =