Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author WPAutoLogin

    (@wpautologin)

    Hi there!

    It should be quite easy to reconstruct from the source code, but the autologin codes are saved in the user-metadata table of the MySQL database using the meta_key “pkg_autologin_code”. I will not provide a way to automatically generate a autologin link for users because of security concerns (one would automatically generate a way to bypass regular logins for any user that registers), but if you really want to do this, you can write a randomly generated string with the given meta_key and that will be that user’s autologin code. However, be aware that of the security issues of doing so!

    Thread Starter ngrudev

    (@ngrudev)

    Hi, thanks for your answer! Can you provide me a code to put in my functions.php to automatically generate a autologin link, when new user is created? You can think about adding a setting option, for those who want this auto function (like me ?? It can be turned off by default, but with the option to enable it. Ofcoure there will be message for caution when using this option.

    Thanks again,
    Niki

    Plugin Author WPAutoLogin

    (@wpautologin)

    Hi Niki!

    I know that this is desirable, but I consider the current state of the plugin to not cause too much issues with secret backdoors if it is just installed. Anything that allows users to automatically be assigned an autologin-code would open a backdoor for potentially unsuspecting users of this plugin. When looking at all the wordpress websites that are on the web, it just seems like a very irresponsible addition to the plugin – just because it is hard to explain to someone in which ways such a function might be misused on some sites.

    I personally do not have time to provide the code for the feature that you are looking for. It entails looking up the correct wordpress-event and then doing the database-stuff that I am currently doing in the plugin code. It takes me too much of my time to provide this one-off feature for free here. But if you find somebody who is able to modify PHP-code, he should be able to code that feature for you. It should be approximately 20-30 lines of code with a lot of looking-things-up, I think (3-4 hours of work).

    I hope that you find(found?) a solution that works for you.

    • This reply was modified 8 years, 5 months ago by WPAutoLogin.
    Thread Starter ngrudev

    (@ngrudev)

    yes, i wrote a simple code and have done the job ??

    10x

    Hi @ngrudev!
    I actually have the exact same need as you did.
    You seemed to have solved it already. Any chance you could share your code?
    Thanks a lot!

    Thread Starter ngrudev

    (@ngrudev)

    just put this code in your functions.php

    //generate autologin links for registeret users
    function generateRandomString($length = 60) {
        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $charactersLength = strlen($characters);
        $randomString = '';
        for ($i = 0; $i < $length; $i++) {
            $randomString .= $characters[rand(0, $charactersLength - 1)];
        }
        return $randomString;
    }
    add_action( 'user_register', 'myplugin_registration_save', 10, 1 );
    function myplugin_registration_save( $user_id , $length ) {
    	$meta_key = "pkg_autologin_code";
    	$timestampz=time();
    	$tokenparta = generateRandomString();
    	$key = $timestampz*3 . $tokenparta;
    	update_user_meta( $user_id, $meta_key, $key );
    }

    Thanks a lot I’ll try it!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Auto create autologin link when user is created’ is closed to new replies.