The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Hide all frm_display pages for good - without making them private!

Labels

This Discussion is public

Notifications

In the thread here it was suggested that one hide the frm_display pages from unauthorized access by making them all private. But what if you want users who can't view private pages to be able to access them, but not members of the general public? Or you have a ton of views you don't want to go through and deal with setting to private?

I created a custom permission (called view_teams) using the User Role Editor plugin, and assigned it to all the user levels that I wanted to be able to view frm_display pages. Then I copied single.php from my theme into single-frm_display.php and added the following php code surrounding the content area of the page (php tags omitted to get my code to display on this forum).

if ( current_user_can('view_teams') ) {
//Page content goes here.
} else {echo "Sorry, you are not authorized to view this page.";}

Voila - logged in users with the view_teams permission can view the frm_display pages - everyone else can't.

Of course, make sure you make this change in a child theme so you don't lose it in a theme update.

Discussion closed.