Last active
September 6, 2019 10:49
-
-
Save champsupertramp/94cc187387ea3d8593aff57a472b92fe to your computer and use it in GitHub Desktop.
Ultimate Member - Restrict specific user roles from accessing profile page
This file contains hidden or 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 | |
/** | |
* 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 | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?