0

My membership plug in won't let me re-direct custom post type archive / taxonomy URLs to a non-member page if the user requesting access is not logged in or not a member. So, I am trying a hack to check if user is Level A, B, C etc and if not the template page redirects to a no access page.

I'm using the code below to check for access levels. What would be the best way to insert a page redirect?

<?php 
     if(mgm_user_is(array('level1','level2' ))) {

echo 'REDIRECT TO NON-MEMBER PAGE';

} else {
echo 'GIVES ACCESS TO PAGE SEARCHED FOR';
} ?> 

1 Answer 1

2

You can use use wp_redirect for that. Here is a simple code, it redirects non-users to website homepage. You can redirect them to a error page or on signup page.

<?php
  if( mgm_user_is( array('level1', 'level2' ) ) ) {
    wp_redirect( home_url() );
    exit;
  } else {
    // show content
  }
?>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.