Private member page

I need to make a private page for subscribers in my Wordpress website I don’t want to use plugins so I’m asking what is better, add the capability to subscribers to read private pages or maybe create a custom page template with conditions?

Topic members membership customization Wordpress

Category Web


You can do it without plugins, you just have to allow subscribers to see Private posts and pages, depending on what you want, so you have to put this code in your functions.php

$subRole = get_role( 'subscriber' );
$subRole->add_cap( 'read_private_posts' );
$subRole->add_cap( 'read_private_pages' );

And then simply create a private post or page and it will works as expected. Tested.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.