Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save champsupertramp/94cc187387ea3d8593aff57a472b92fe to your computer and use it in GitHub Desktop.
Save champsupertramp/94cc187387ea3d8593aff57a472b92fe to your computer and use it in GitHub Desktop.
Ultimate Member - Restrict specific user roles from accessing profile page
<?php
/**
* Restrict specific user roles from accessing profile page
*/
add_action("template_redirect","um_custom_page_restriction", 9999 );
function um_custom_page_restriction(){
$hide_from_roles = array( 'child','stranger' );
if ( um_is_core_page('user') && um_get_requested_user() ) {
if( is_user_logged_in() && in_array( um_user('role'), $hide_from_roles ) ){
exit( wp_redirect( get_bloginfo('siteurl') ) ); // redirect
// You can also return a template file to display message
}
}
}
?>
@klish09
Copy link

klish09 commented Jul 7, 2016

let say that.....the rol name that i would like to restrict is "Spanish Techer " and i would like to Redirect it to "mysite/custompage " ..how can i do that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment