Exclude URLs
-
+1
Hi,
this article helped me:
https://premium.wpmudev.org/forums/topic/exclude-pages-password-protected-plugin#post-660341I also had to add some code because it doesn’t work if you share the link in some website that modifies it (i.e. Facebook).
The final code is:
//remeber to add urls that result from people writing things like yourdomain.com instead of www.yourdomain.com: Password protected redirects them and doesn't show what you need, i.e. your home page. You can copy/paste them from the address bar. $url_exclude = array( 'https://www.........com', 'http://.......com', 'http://www.......com/?password-protected=login&redirect_to=http%3A%2F%2F..........com%2F); //Other exceptions $bOtherExc = false; //if url is shared in FB - really raw check... if(strstr($_SERVER['REQUEST_URI'], 'com%2F%3Ffbclid')) { $bOtherExc = true; } if( is_ssl() == 'https') { $protocol = 'https'; } else { $protocol = 'http'; } $current_link = $protocol."://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; if(in_array($current_link,$url_exclude) || $bOtherExc){ return; }Thanks teonsight!
Thanks @teonsight ! Everything works great, but the FB link. It still requires for login when users come from FB.
Let’s say the site url is test.ro, my code looks like this:$url_exclude = array('https://test.ro/', 'http://test.ro/', 'http://test.ro/?password-protected=login&redirect_to=http%3A%2F%2Ftest.ro%2F)'; //Other exceptions $bOtherExc = false; //if url is shared in FB - really raw check... if(strstr($_SERVER['REQUEST_URI'], 'ro%2F%3Ffbclid')) { $bOtherExc = true; } if( is_ssl() == 'https') { $protocol = 'https'; } else { $protocol = 'http'; } $current_link = $protocol."://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; if(in_array($current_link,$url_exclude) || $bOtherExc){ return; }Is there anything else that I need to change?
Thanks in advance!Maybe because my check is just for links in comments. I tried to share a link in a post and the url created was:
http://www.test.com/?fbclid=IwAR17l…so try to change line 7 like this:
if(strstr($_SERVER['REQUEST_URI'], 'ro%2F%3Ffbclid') || strstr($_SERVER['REQUEST_URI'], 'ro/?fbclid')) {Anyway I think that – with (one of) the last relase – the autor added an hook to add this check without modyfing the plugin but I didn’t try.
The topic ‘Exclude URLs’ is closed to new replies.