Free Directory, Listing & Classifieds WordPress Plugin Support Extensions Memberships Membership restriction attributes AND pages

Membership restriction attributes AND pages

  • Author
  • elioberga

    Hi ihor,
    in hivepress settings I can decide wether to restrict an attribute (that I choose in the plan page) or the single listing page. I can’t select both? I need to restrict just some attributes AND just some other random pages I create (not the listing pages), why there is not the possibility to select both?



    Since it’s a HivePress extension it restricts access to HivePress content (listings, vendors and features of other extensions like Reviews or Messages), but there’s a PHP snippet that you can use to restrict access to regular WordPress pages:

    	function() {
    		if ( current_user_can( 'edit_others_posts' ) || ! function_exists( 'hivepress' ) ) {
    		if ( is_page( [ 'one', 'two', 'three' ] ) && ! hivepress()->request->get_context( 'membership' ) ) {
    			wp_safe_redirect( hivepress()->router->get_url( 'membership_plans_view_page' ) );

    Replace “one”, “two”, “three” with page slugs.


    Thank ihor.
    this snippet should be valid for any membership plan, is it? how can I restrict just to one plan?
    It should be something like:

    if ( current_user_can( ‘HAVE MEMBERSHIP PREMIUM’ )

    what should be written instead of HAVE MEMBERSHIP PREMIUM?



    I tried but an external user not even logged in can still enter the page..


    Yes, it works if any membership is purchased, membership-specific restrictions for pages would require advanced customizations. Please make sure that you set the correct page slugs, I’ve just tested it with “sample-page” (the default WordPress page) and it redirects me back to the home page if I don’t have a membership.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.


Sign In

Don't have an account? Register

Forgot password?


Already have an account? Sign In

Forgot password?

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.

Cyber Monday is here! Get 25% off with MONDAY2020 coupon code until Monday, December 7.