used for guest user (Users that are not logged in)
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;
}
}