• Resolved jamesict

    (@jamesict)


    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/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jamesict

    (@jamesict)

    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

    (@strangerstudios)

    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");

    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.

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.