If logged in, after re-visiting will automatically take them to the Login Welcome Page

Hello all.

Running the PRO version of S2Member.

Currently, members come to the site and log in to their area and visit restricted content.
Then they leave the site for whatever the reason.
Later on when they come back, a day later or a week later, and they are still logged in and they land on my site’s regular home page.

Question: Is there any way to automatically take these members who are already logged in to S2Member’s Login Welcome Page when they land on my site after a week…???

Thank you in advance for any help.

Not directly, but you could always install a plugin that automatically logs users out after a specified period of inactivity.

Thanks for the response.

I do not want them to be logged out. I want them to be taken to the S2Member Login Welcome Page if they had previously logged in and the system had not logged them out yet.

Users of my site are senior citizens and this would make it a bit simpler for them as they are very familiar with the way the Login Welcome Page is laid out.

If this cannot be done within S2Member with a bit of slick coding, can you suggest a plugin that can do this…??

It’s nothing to do with s2Member. This is just WordPress. So really you are asking in the wrong place. I suggest a Google.

So your answer to this question is [quote=“KTS915, post:4, topic:1872”]
I suggest a Google.
[/quote]

Ok, thanks.

There is a way, but needs to build some code: in your header.php set a check if the user is logged in, and if so, redirect him to your LWP (but save a cookie that he was redirected, or will fall in continuous reload).

Appreciate the response krumpch.

As I have absolutely no idea how to do this and not break something else, can you please help me with this code…??

Thanks again.

Well, “code copy/paste” always can break something… I can create the code “as I imagine it”, but I don’t know your theme, and is it a child theme, or custom one etc, there is lot of guessing I must do before to start the code. If you can not do, better ask a developer.

Hi krumch.

I understand your concerns. I know how to tweak a piece of code to make it work by trail and error. But, the problem is, I don’t have that piece of code…:frowning:

If you would be willing to do that for me (and for others who may be looking for this same functionality in the future) that would be great. I wish you would re-consider. The site is running a child theme for Avada.

At any event, appreciate your time.

OK, here is it:

<?php
If(is_user_logged_in() and !isset($_COOKIE["mylogincheck"])) {
  setcookie("mylogincheck", "1", 0, "/", "your_site.com");
  wp_redirect(home_url("/login_welcome_page"));
  exit;
}
?>

You will need to replace “your_site.com” with your domain and “/login_welcome_page” with relative path to your LWP.

Hope that helps :slight_smile:

Thanks Krum!!

I really appreciate it. I am sure many others will find this useful in the future.

I did not have time to understand what this code is doing but I did include it right at the very top of my header.php file.

Unfortunately after that, if I clicked on any link on the site, it just kept on spinning and then timed out.

I will try and figure it out but in the mean time if you have any suggestions please let me know.

Thanks again.

Also, I think all these conditions need to be met too:

is_user_logged_in() && is_home() && empty($_SERVER['HTTP_REFERER']) && ! is_page('members.php').

Can not agree with “empty($_SERVER['HTTP_REFERER'])” check - people may click a link in mails, archives etc… Also “is_home()” and “!is_page(‘members.php’)” not need to be both there - they are antagonists. Also there is no page like ‘members.php’…

And all this means again the same: In this case I can not create usable code, without to see the site “inside”… :-/ If you need me, please don’t post account info here, but on private message.