Title: Making a few pages viewable after adding code to functions.php
Last modified: August 20, 2016

---

# Making a few pages viewable after adding code to functions.php

 *  Resolved [jamesict](https://wordpress.org/support/users/jamesict/)
 * (@jamesict)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/making-a-few-pages-viewable-after-adding-code-to-functionsphp/)
 * Hi,
 * 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
       	if(!$current_user->ID
       		&& !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'])));
       	}
       	elseif(is_page()
       			&& !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.
       		wp_redirect(home_url());
       	}
       }
       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.
 * [http://wordpress.org/extend/plugins/paid-memberships-pro/](http://wordpress.org/extend/plugins/paid-memberships-pro/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [jamesict](https://wordpress.org/support/users/jamesict/)
 * (@jamesict)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/making-a-few-pages-viewable-after-adding-code-to-functionsphp/#post-3517003)
 * Whoops!
 * 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!
 *  Plugin Author [Jason Coleman](https://wordpress.org/support/users/strangerstudios/)
 * (@strangerstudios)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/making-a-few-pages-viewable-after-adding-code-to-functionsphp/#post-3517065)
 * 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");
       ```
   
 *  [PMPro-Lisa](https://wordpress.org/support/users/pmpro-lisa/)
 * (@pmpro-lisa)
 * [13 years ago](https://wordpress.org/support/topic/making-a-few-pages-viewable-after-adding-code-to-functionsphp/#post-3517076)
 * 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](http://www.paidmembershipspro.com/pricing).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Making a few pages viewable after adding code to functions.php’ is closed
to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/paid-memberships-pro_f1dacb.svg)
 * [Paid Memberships Pro - Content Restriction, User Registration, & Paid Subscriptions](https://wordpress.org/plugins/paid-memberships-pro/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/paid-memberships-pro/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/paid-memberships-pro/)
 * [Active Topics](https://wordpress.org/support/plugin/paid-memberships-pro/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/paid-memberships-pro/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/paid-memberships-pro/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [PMPro-Lisa](https://wordpress.org/support/users/pmpro-lisa/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/making-a-few-pages-viewable-after-adding-code-to-functionsphp/#post-3517076)
 * Status: resolved