Paid Memberships Pro
[resolved] Making a few pages viewable after adding code to functions.php (4 posts)

  1. JamesICT
    Posted 3 years ago #


    Just trying out your plugin and having one or two problems.

    //redirect to login or homepage if user is logged out or not a member
    function my_template_redirect()
    	global $current_user;
    	$okay_pages = array(pmpro_getOption('billing_page_id'), pmpro_getOption('account_page_id'), pmpro_getOption('levels_page_id'), pmpro_getOption('checkout_page_id'), pmpro_getOption('confirmation_page_id'));
    	//if the user doesn't have a membership, send them home
    		&& !is_front_page()
    		&& !is_page($okay_pages)
    		&& !strpos($_SERVER['REQUEST_URI'], "login"))
    		wp_redirect(home_url("wp-login.php?redirect_to=" . urlencode($_SERVER['REQUEST_URI'])));
    			&& !is_front_page()
    			&& !is_page($okay_pages)
    			&& !$current_user->membership_level->ID)
    		//change this to wp_redirect(pmpro_url("levels")); to redirect to the levels page.
    add_action('template_redirect', 'my_template_redirect');

    1. I have added the code above to my functions.php and it works very well, however, I am having trouble adding those few pages that I still want to be accessible to visitors.

    For instance, if a page is titled 'Contact' and has a slug of 'contact', how is this added. All of my attempts so far, have failed.

    2. I have a couple of users on the site who do not need to pay but I would like to add them to the new members list, whereas at the moment, they are only listed in the normal WP users section. Can I add them manually somehow?

    Thank you if anyone has the knowledge and can help.


  2. JamesICT
    Posted 3 years ago #


    It now seems that this code has blocked me out of my site. I am unable to access wp-login.php or wp-admin at all. It keeps redirecting me to the site front page instead.

    Does anyone know how to over-ride the above code at all?

    At this stage my only other option is to delete my existing database and re-install, but doing so will mean I lose quite a bit of work.

    Any help is hugely appreciated!

  3. Jason Coleman
    Plugin Author

    Posted 3 years ago #

    James, FTP to your site to remove this code or rename the PMPro folder to deactivate it.

    To add more pages to be excluded, add it to the $okay_pages array, e.g...

    $okay_pages = array(pmpro_getOption('billing_page_id'), pmpro_getOption('account_page_id'), pmpro_getOption('levels_page_id'), pmpro_getOption('checkout_page_id'), pmpro_getOption('confirmation_page_id'), "contact", "my-other-slug", "etc-etc");
  4. PMPro-Lisa
    Posted 3 years ago #

    Hi James,

    Since we've not heard back from you, I'm going to close this thread. If you'd like to join our developers forum, please sign up at http://www.paidmembershipspro.com/pricing.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Paid Memberships Pro
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic