Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello
    Add this below code in functions.php under theme

    function wpse_131562_redirect() {
    if (
    ! is_user_logged_in()
    && (is_cart() || is_checkout())
    ) {
    // feel free to customize the following line to suit your needs
    wp_redirect(home_url());
    exit;
    }
    }
    add_action(‘template_redirect’, ‘wpse_131562_redirect’);

    Thread Starter baburman

    (@baburman)

    Well, I have done it my way. I added this code in my previously written user_init_func in my plugin.

    if( $_SERVER[‘REQUEST_URI’] == ‘/’){
    $redirect_to = get_option(‘siteurl’). ‘/ads’;
    wp_safe_redirect( $redirect_to );
    exit();
    }

    Where user_init_funct is hooked this way:

    add_action(‘init’, ‘user_init_func’);

    I wonder why didn’t i give it a thought before. Anyways prakash thanks for your help!

    baburman

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to do page redirect?’ is closed to new replies.