Created
April 23, 2020 06:42
-
-
Save plugin-republic/d4ee38979bbcdd56d847b489cad0c952 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Change the redirect URL depending on user role | |
*/ | |
function prefix_redirect_url_per_role( $url ) { | |
// Get the current user roles | |
$roles = wcmo_get_current_user_roles(); | |
if( in_array( 'gold', $roles ) ) { | |
// Redirect to specific page for Gold role | |
return 'http://yournewurl.com/gold'; | |
} else if( in_array( 'silver', $roles ) ) { | |
// Redirect to specific page for Gold role | |
return 'http://yournewurl.com/silver'; | |
} | |
// This is the default URL | |
return $url; | |
} | |
add_filter( 'wcmo_redirect_url', 'prefix_redirect_url_per_role' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment