What's the best way to restrict access to pages for Pro Users only, on the main website?

I'm referring to pages I write on the main website, something like restricting a specific category to Pro users, only.

The Membership plugin does exactly this but there is no integration with Pro Sites.

Thanks!

  • DavidM
    • DEV MAN’s Mascot

    Hi transparencia,

    Really, the only way I can imagine to achieve that would be using Membership, which is a user-based plugin. Pro Sites is actually a site-based plugin and doesn't reference users, per se.

    Pro Sites is still backward compatible with Supporter in various ways, the chief of them being the Supporter status. The Membership Supporter integration option still attaches the Supporter status to a Membership subscription. If you have only one premium level in Pro Sites, it should use that.

    Would that perhaps work for you?

    We'll still have to have a look at an update for Membership with Pro Sites support but I'm just wondering if this might work for you currently.

    Cheers,
    David

  • Jonathan
    • The Incredible Code Injector

    @transparencia,

    If I am not mistaken, pro sites has a function that checks if user is supporter. I know that suppoter plugin had it - it was something like is_supporter and it results in either true or false.

    So you could use that?
    Here is something I wrote out for another member who wanted something simple, but you could change it by adding in the is_supporter check (don't know off hand what it is called). So replace is_user_logged_in with is_supporter check and you can change what you want to happen. Currently it just directs to login page.

    Here is code.

    /* restricted category array can be term_ID 9, or slug "blue-cheese", or name "Stinky Cheeses" */
    add_action( 'template_redirect', 'user_has_access_check', 1 );
    function user_has_access_check() {
    
    	/* Check if in restricted categories.*/
    	if ( in_category( array( 9, 'blue-cheese','Stinky Cheeses' ) ) ) {
    
    		/* If user isn't logged in redirect to login page */
    		if ( !is_user_logged_in() )
    			auth_redirect();
    	}
    }

    Of course I could be completely off track as I don't use supporter/pro sites and am just speaking out of what I heard/seen :wink:

  • Jonathan
    • The Incredible Code Injector

    Thanks for that @masonjames :wink: I didn't know off hand what the filter was called...
    I'll bookmark this thread for future reference.

    @transparencia,
    Now that masonjames has provided a way to check if user belongs to particular pro site level - you can pretty much do anything you want as far as restriction goes.
    Best of luck!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.