Skip to content

Instantly share code, notes, and snippets.

Created September 18, 2013 03:06
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 anonymous/6603981 to your computer and use it in GitHub Desktop.
Save anonymous/6603981 to your computer and use it in GitHub Desktop.
add_action('pre_get_posts','redirect_non_subscribers');
function redirect_non_subscribers() {
if (is_user_logged_in() && !current_user_is_member()) {
$options = get_option('membership_options', array());
if (!is_page($options['registration_page']) && !is_page($options['registrationcompleted_page'])) {
wp_redirect( get_permalink($options['registration_page']) );
exit;
}
}
}
add_action('admin_init','redirect_non_subscribers_admin');
function redirect_non_subscribers_admin(){
if (is_user_logged_in() && !current_user_is_member() && !current_user_can('manage_options')) {
$options = get_option('membership_options', array());
wp_redirect( get_permalink($options['registration_page']) );
exit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment