Whitelist Dynamic URLs Error
-
Hi,
I’d like to add exceptions for dynamic pages. I was trying this code according to the Github help:
The webpage I’d like to add is:
https://x.y.z/?page_id=2
The following code works but also allows to see all pages with page_id without a loginfunction my_forcelogin_whitelist( $whitelist ) {
// whitelist URL if query string contains ‘parameter’
if( isset($_GET[‘page_id’]) ) {
$whitelist[] = site_url($_SERVER[‘REQUEST_URI’]);
}
// whitelist URL where ‘value’ is equal to query string ‘parameter’
if( $_GET[‘page_id’] == ’20’ ) {
$whitelist[] = site_url($_SERVER[‘REQUEST_URI’]);
}
return $whitelist;
}
add_filter(‘v_forcelogin_whitelist’, ‘my_forcelogin_whitelist’, 10, 1);
///////If I use the following code to restrict the filter only for the page_id=20 then I get my site broken.
function my_forcelogin_whitelist( $whitelist ) {
// whitelist URL where ‘value’ is equal to query string ‘parameter’
if( isset($_GET[‘page_id’] == ’20’ )) {
$whitelist[] = site_url($_SERVER[‘REQUEST_URI’]);
}
return $whitelist;
}
add_filter(‘v_forcelogin_whitelist’, ‘my_forcelogin_whitelist’, 10, 1);
/////////////
In both cases I put the code in the end of the functions.php fileCould you tell me what am I doing wrong?
Thank you
- The topic ‘Whitelist Dynamic URLs Error’ is closed to new replies.