Use a single login, and tag each user as either a buyer or a seller using user meta
e.g. lets use a user meta field called shireefs_login_tag
To set the tag:
update_user_meta( $user_id, 'shireefs_login_tag', 'buyer' );
To read the tag:
get_user_meta( $user_id, 'shireefs_login_tag', true );
To redirect on login:
function my_login_redirect( $redirect_to, $request, $user ) {
if ( !empty( $redirect_to ) {
return $redirect_to; // dont mess with existing redirects
}
//is there a user to check?
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
//check for admins
$login_tag = get_user_meta( $user->ID, 'shireefs_login_tag', true );
if ( 'buyer' === $login_tag ) {
return home_url( 'buyers' ); // example.com/buyers
} else if ( 'seller' === $login_tag ) {
return home_url( 'sellers' ); // example.com/sellers
} else {
return home_url( 'choose' ); // example.com/choose, we dont know if they're a buyer or a seller yet
}
} else {
return $redirect_to;
}
}
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );
With this information you now know how to:
- store if a user is a buyer or a seller
- retrieve that information so that you can do things with it
- redirect users to a location based on that info when they log in
Everything else can be built off of those