Login Redirect - Multiple Scenarios

I'm trying to create some code that will accomplish the following:

  1. If login from any page in this array(example-page-one, example-page-two, example-page-three){ then, simply refresh the page

  2. } elseif login from 'example-page-four' { then, redirect to 'payment-page'

  3. } elseif login from all other pages { then redirect to '/member-account' }

So far, all I've accomplished is pulling out my hair. Any help would be greatly appreciated. I have very limited coding skills here. This is what I've cobbled together so far to test, but it doesn't work:

function custom_user_login_redirect($redirect_url) {

$page = str_replace('/', '', $_SERVER['REQUEST_URI']);


switch($page) {
    case 'example-page-one':
        return site_url('/example-page-one');
        break;

    default:
        return site_url('/member-account');
        break;
}
}

add_filter( 'login_redirect', 'custom_user_login_redirect' );

I know this code won't get me to all three requirements above, but I figured if I could at least get this to work, I might have a shot at getting the rest of it. Help!

Topic switch redirect login Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.