Skip to content

Instantly share code, notes, and snippets.

@plugin-republic
Created April 23, 2020 06:42
Show Gist options
  • Save plugin-republic/d4ee38979bbcdd56d847b489cad0c952 to your computer and use it in GitHub Desktop.
Save plugin-republic/d4ee38979bbcdd56d847b489cad0c952 to your computer and use it in GitHub Desktop.
<?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