Create an Action to check restriction status
-
Can someone help me create a simple WP action to test whether the current visitor is restricted, so that I can run some code based on the result?
I see many people here have asked for a filter to give restricted visitors access to specific pages. The stock reply (see below) is working fine for me.
So I thought that in my
functions.php
I could simply changeadd_filter
toadd_action
, and check the value of$is_restricted
. But that doesn’t work ($is_restricted
is always true). What stupid error am I making? Is$is_restricted
out of scope, and if so, is there a way round this?Many thanks for any suggestions.
add_filter( 'restricted_site_access_is_restricted', 'my_allow_access', 10, 2 ); function my_allow_access( $is_restricted, $wp ) { if( 'about' === $wp->request ) { return false; } return $is_restricted; }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Create an Action to check restriction status’ is closed to new replies.