Last active
August 14, 2016 22:33
-
-
Save chuckreynolds/79504c2e28090c94a90a to your computer and use it in GitHub Desktop.
Restrict Content Pro doesn't seem to automatically protect post, category, taxonomy, custom post type, archives. This is a problem for me. It will however protect pages when the settings are correct so I made this redirect action for the top of my archive.php, taxonomy.php, single.php, page.php pages. This will work too when using template files…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Global Action to check if RCP user is logged; if not -> auth. | |
| * | |
| * RCP doesn't seem to protect archives that aren't pages or all posts/pages | |
| * by default so this is my fix. | |
| */ | |
| function chuck_is_rcp_active () { | |
| if ( ! rcp_is_active() ) : | |
| wp_redirect( home_url( '/auth/' ) ); | |
| exit; | |
| endif; | |
| } | |
| add_action( 'chuck_rcp_check', 'chuck_is_rcp_active' ); | |
| /** | |
| * SO. In order to call this use the following at the top of any | |
| * template pages you want to secure; like single.php, page.php, etc | |
| */ | |
| /** | |
| * RCP auth check | |
| */ | |
| do_action( 'chuck_rcp_check' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I am using the RCP plugin but I need it to protect a category archive page (which it is not currently). It sounds like you had the same problem and solved it with this, but I am unsure how to implement your solution. Do I just add this to the top of my category.php file? I am using a Genesis child theme, so would I create a copy of the category.php file in my child theme's root directory and then past this code at the top or is that the wrong way to implement your solution?