Solved

Direct acess from email-link to a password protected wordpress site

Posted on 2011-03-09
5
169 Views
Last Modified: 2012-05-11
I have a client where part of the site is a member section, where pople have to log in with a user name and password given from webmaster, to get access.

The user is registered in the database.

It is now a need for having the opportunity to click on a link in a received e-mail who takes you to the member area without login in manually.

I would be impressed if anyone know how this can be done in Wordpress, and also if they tried to explain it to me.

Thanks!
0
Comment
Question by:toiler
  • 3
5 Comments
 
LVL 31

Expert Comment

by:gwkg
ID: 35089689
Wordpress would be pretty insecure if that were possible.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35089695
It's possible, just a heckuva lot of extra work and totally circumvents all of the hard work that went into making WordPress secure.
0
 
LVL 31

Expert Comment

by:gwkg
ID: 35089779
This should do it

If you add the users name into the url as 'user' and a secret key as 'key', try this in your functions.php file:

function auto_login() {
if (!is_user_logged_in() && $_GET['key']='your-secret-key') {

$user_login = $_GET['user'];

//get user's ID
$user = get_userdatabylogin($user_login);
$user_id = $user->ID;

//login
wp_set_current_user($user_id, $user_login);
wp_set_auth_cookie($user_id);
do_action('wp_login', $user_login);
}
}
add_action('init', 'auto_login');
0
 

Author Comment

by:toiler
ID: 35093359
Thanks alot for help!

gwkg:
Do I have to make this link manually for each member mail? You see, we are talking about  500 members.
0
 
LVL 31

Accepted Solution

by:
gwkg earned 500 total points
ID: 35096121
If you want to log each person in to their own account the link would need their user name.  If you are using something like Constant Contact, MailChimp, etc. to do the mailing you should be able to make a userdefined field that you can put each persons user name into one time and then include it in the email link as a variable that changes for each person in the same way you would put Hi ##FIRSTNAME##, to personalize the email.

The other way would be to have one generic account that everyone logs into to the see the content.  Of course this will be even less secure.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you use a default hosting installation of wordpress with the intention of it being your actual site?  Maybe you’ve installed it as a Blog to your current site and recently converted it to be the main site and do away with the old .htm pages.  An…
Now that you've installed WordPress 2.9 (http://www.experts-exchange.com/articles/Web_Development/Blogs/WordPress/WordPress-2-9-What-to-Expect-When-Upgrading-to-WordPress-2-9.html?) on your site, you need to install some plugins to get the most out …
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question