• Resolved WP CMS Ninja

    (@billiardgreg)


    Is there a way to require a login to access any pmpro pages. I have run into an instance where there is a custom register page for a site that creates the user but when using pmpro and you select a level it brings to pmpro’s register page. I tried doing: add_filter(‘pmpro_register_redirect’, ‘__return_false’); in an attempt to not have it control the register redirect but still bringing me to the check out page of pmpro where it asks to register as well. So if there is a way to either make it redirect to the correct user register page before checkout or i want to make the system require login before any membership level page.

    https://www.ads-software.com/plugins/paid-memberships-pro/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jason Coleman

    (@strangerstudios)

    Membership pages require membership, which requires a user account. So PMPro does effectively require a login to access membership pages. I think I don’t understand what you really mean by “require login”.

    The add_filter… code you mentioned is the correct way to tell PMPro to NOT redirect the default WP register page to the PMPro levels page. Are you trying then to have users redirect to the levels page after doing the default registration?

    Couple notes.

    1. In the PMPro advanced settings page, you can change the text shown to non-members and non-users. You can make the non-members text link to the levels page and the non-users text still link to the register page.

    2. Custom code could be written that hooks into template_redirect and if the current user is not a member redirects them to the levels page. It would be something like this:

    https://www.paidmembershipspro.com/2011/11/lock-down-everything-but-homepage-for-non-users/

    (article is behind our paywall, so here is just the code: https://gist.github.com/strangerstudios/1332730)

    Thread Starter WP CMS Ninja

    (@billiardgreg)

    I was able to make it so that if user is not logged in and if page is in the no okay pages based off of the gitbug link you posted. Here is that code:

    function my_template_redirect()
    {
    	global $current_user;
    
    	$not_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 (!$current_user->ID && is_page($not_okay_pages)) {
    			wp_redirect(home_url("/login/?redirect_to=" . urlencode($_SERVER['REQUEST_URI']) ));
    	}
    
    }
    add_action('template_redirect', 'my_template_redirect');
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘require login for pmpro’ is closed to new replies.