I Need Help Writing A Custom Function to Redirect Non-Logged in Users.
-
First off, I’ve just installed Justin Tadock’s Members Plugin to get access to the Restrict Roles Template tags. What I’d like to do is make it so that specific components of my BP install are only available to certain roles.
This is the code I’ve come up with so far:
if ( bp_is_active( ‘profile’ | ‘activity’ | ‘messages’ | ‘friends’ | ‘groups’ | ‘settings’ ) && function_exists( ‘current_user_has_role’ ) && current_user_has_role( ‘subscriber’ | ‘moderator’ | ‘administrator’ ) ) {
// the BP Component is “Profile, Activity, Messages, Friends, Groups, or Settings”, and the users role is “Subscriber, Moderator, or Administrator”display the component; // I don’t know what to put here so that the component is displayed if the user has the right role.
}else {
wp_redirect(get_option(‘siteurl’) . ‘/page-of-my-choice.php’);; // redirects user who don’t have the correct role to my page of my choice
}Any Ideas on how to make this work?
- The topic ‘I Need Help Writing A Custom Function to Redirect Non-Logged in Users.’ is closed to new replies.