Find Answers and Get Support › Forums › Gwangi – PRO Multi-Purpose Membership, Social Network & BuddyPress Community Theme › Compatible Plugins › Paid Memberships Pro › restrict content access to users
- This topic has 4 replies, 2 voices, and was last updated 6 years, 4 months ago by
Themosaurus.
-
AuthorPosts
-
alexParticipant@abourne
- 81 Topics
- 259 Posts
I wish to restrict access for non-members/unregistered to open a post, but still be able to see the page for where all the posts are as tiles.
I.e.
Be able to view: https://www.gymn.com.au/benefits/ which is the blog page
But restricted content access to the post: https://www.gymn.com.au/benefits/support-when-you-need-it/I spent countless hours and seemingly tried every available plugin – most of which break the registration procedure or cause fatal errors…
What function or filter can be used?
Note: I cannot use a shortcode on each post. It must instead be a generic option to restrict every post to unregisted users.
November 1, 2018 at 21:24 #3218@themosaurus- 1 Topics
- 1675 Posts
Hi @abourne,
This seems odd because one of the basic features of PMPRO is to be able to prevent access to a content (a post) according to a plan:
However, you can try this simple snippet:
/** * Redirect non logged-in users to registration page if they visit a single post page */ function user_single_page_template_redirect() { if( ! is_user_logged_in() && is_singular( 'post' ) ) { wp_redirect( home_url( '/register/' ) ); exit(); } } add_action( 'template_redirect', 'user_single_page_template_redirect' );
Best regards,
November 2, 2018 at 12:46 #3232@themosaurus- 1 Topics
- 1675 Posts
You’re welcome. ?
Best regards,
November 5, 2018 at 16:23 #3305 -
AuthorPosts
The topic ‘restrict content access to users’ is closed to new replies.