• morbidcuriosity

    (@morbidcuriosity)


    Hello,

    I have a website where all our key account managers have their own login. The login is really simple – it’s the personal code of account manager both as user name and password and it’s because they share these accounts with their customers so we wanted to make this clear and easy to use. Let’s say that these accounts are more or less public – anyone who knows the personal code of our account manager can use it to see more detailed offers on our website and thanks to this we can even watch who’s customer made which order. These users are not able to change their names, passwords or anything else and their user role is ‘subscriber’ so they can’t get to admin of website.

    What I need now is to find a way how to let our customers login to our website as their managers without filling user name and password because sometimes it’s just two more steps which are difficult for some of our customers and they don’t want to do it. I would like to have the possibility to generate link which would be unique for every user of course and which automatically log in the customer when they click it.
    I found plugin Autologin Links (https://cs.wordpress.org/plugins/autologin-links/) which can do exactly what I need but I cannot customize the URL and that’s the problem because I need to make URL with manager’s personal code in it. Our managers can remember their personal codes but they would definitely not remember other code which furthemore even can’t be remebered because the plugin generates URLs like “http://example.com/?autologin_code=8GtA2blWDy0LoSjcAbfM4U2g6JTIIn”.

    Is there any way to do this? To generate URL which our customers could log in with and which would look like I want – for example “http://example.com/?autologin_code=MY-CODE-1234”?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Sorry for the slow reply. You can use an URL such as example.com/wp-login.php?action=login&log={username}&pwd={plaintext} in combination with hooking “wp_authenticate” filter. WP passes POSTed credentials, but yours are GET values, so your authentication code needs to get the credentials from $_GET, sanitize and validate, then set the passed by reference credentials to the values so gotten.

    If you hook this filter with a small priority number, such as 0, WP should be able to properly authenticate from there using the values you set. Your code would of course first verify if the credentials are in $_GET. If not, the request is probably from a legitimate login form and you should return without doing anything.

    Untested, but should work.

Viewing 1 replies (of 1 total)
  • The topic ‘Autologin with URL’ is closed to new replies.