maddy maddy - 15 days ago 6
PHP Question

wp redirect is not working or not redirect to actual URL

I want to redirect with specific page i have tried by using

wp_redirect()
but problem is first it go to back end then after I click on visit site it'll go to redirect URL.

So I want it redirect only specific URL not go first backend it only redirect to specified URL.

I have tried following code but it's not redirect properly( it's go first backend then go to actual URL ).

if(!is_super_admin()){
wp_redirect(home_url('/vehicle-repair-managment/'));
exit()
}


What is better way for do this thing right?

Answer
function baw_no_admin_access(){
    if(!is_super_admin()){
       $url=home_url()./vehicle-repair-managment/;
       wp_redirect($url);
       die();
    }   
}
add_action( 'admin_init', 'baw_no_admin_access', 1 );

What you get,Now try wp_redirect.

wp_redirect($url);
Comments