You can just use a standard JavaScript redirect inside an eyesonly shortcode, like so:
[eyesonly logged="out"]
<script>
window.location = "http://www.yoururl.com";
</script>
[/eyesonly]
Or you could show a message and redirect after a certain number of milliseconds, like so:
[eyesonly logged="out"]You need to be logged in to view this. You will be redirected to the login page in 5 seconds.
<script>
setTimeout("location.href = 'http://www.yoursite.com';",5000);
</script>
[/eyesonly]
I’m trying to prevent access to the page to users who are not logged in. This code (below) seems to do that, but rather than leaving them on a blank page I want to redirect them to the login/register page. My attempts to implement the above code suggestions have not worked.
How can this be done?
[eyesonly logged=”in”]
Search
Search our directory below:
[ADVANCEDSEARCH home=yes]
[/eyesonly]
Did you type the above code in the visual or the text editor?
[eyesonly logged="out"]
<script>
window.location = "http://www.yoururl.com/wp-login.php";
</script>
[/eyesonly]
This needs to go in your Text Editor, not the Visual Editor.
Surprised I missed that. Thanks.
Unfortunately, now it redirects me logged in or not.
Here’s how the page is coded (mydomain has the actual domain):
[eyesonly logged=”out”]
<script>
window.location = “http://mydomain/wp-login.php”;
</script>
[/eyesonly]
<h3><span style=”color: #0000ff;”>Search</span></h3>
Search our directory below:
<div class=”row”>[ADVANCEDSEARCH home=yes]</div>
<div class=”row”></div>
<div class=”row”></div>
<div class=”row”></div>
<div class=”row”></div>
<div class=”row”></div>
<div class=”row”></div>
<h3 class=”row”></h3>
<div class=”row”></div>
Do you have administrator override enabled in your settings?
Not sure. Where can I find that and what should it be?
Settings > Eyes Only Options
Not checked.