4images Modifications / Modifikationen > Mods & Plugins (Releases & Support)

[Mod] Lost password for not activated users

(1/3) > >>

V@no:
was wondering if someone can do this:
send activation link along with new password if the user has not activated.
right now I'm not aware the way I as an admin, or a user can reseive email with activation link again if first email was lost...
right now email with registration for new user content username and password, and if a user go to "lost password" he'll receive email with new password, but since he is not activated it wont work.
so, it would be nice for not activated users receive new password AND again activation link.

Vraxor:
HI V@no,

I think I have figured out how to do this, right now I think I must have been crazy I started at this as I really don't need it, but still I thought I was able to do so, so here is what I did:

Open member.php

Find:

--- Code: ---if ($user_email != "") {
    $sql = "SELECT ".get_user_table_field("", "user_id").get_user_table_field(", ", "user_name").get_user_table_field(", ", "user_password")."
--- End code ---


Add:
--- Code: ---get_user_table_field(", ", "user_activationkey").
--- End code ---


So it looks like:

--- Code: ---if ($user_email != "") {
    $sql = "SELECT ".get_user_table_field("", "user_id").get_user_table_field(", ", "user_name").get_user_table_field(", ", "user_password").get_user_table_field(", ", "user_activationkey")."
--- End code ---





Find:

--- Code: ---// Start Emailer
      include(ROOT_PATH.'includes/email.php');
      $site_email = new Email();
      $site_email->set_to($user_email);
      $site_email->set_subject($lang['send_password_emailsubject']);
--- End code ---


After that you will find an array that looks like this:

--- Code: ---$site_email->register_vars(array(
        "user_name" => $checkuser[$user_table_fields['user_name']],
        "user_password" => stripslashes($user_password),
        "site_name" => $config['site_name']
      ));
--- End code ---


Now add:

--- Code: ---"activation_url" => $script_url."/register.php?action=activate&activationkey=".$checkuser[$user_table_fields['user_activationkey']],
--- End code ---


So the end result looks like this:

--- Code: ---// Start Emailer
      include(ROOT_PATH.'includes/email.php');
      $site_email = new Email();
      $site_email->set_to($user_email);
      $site_email->set_subject($lang['send_password_emailsubject']);
      $site_email->register_vars(array(
      "activation_url" => $script_url."/register.php?action=activate&activationkey=".$checkuser[$user_table_fields['user_activationkey']],
        "user_name" => $checkuser[$user_table_fields['user_name']],
        "user_password" => stripslashes($user_password),
        "site_name" => $config['site_name']
      ));
      $site_email->set_body("lost_password", $config['language_dir']);
      $site_email->send_email();
--- End code ---


Now you can use the tag: {activation_url} in your email templates.
Edit the Lost_password template in the Lang/{language}/email folder and add the {activation_url} tag somewhere.

Now upload all and I hope it works, I did tested it myself and for me it worked, but like I said before, I did not need it as my member don't have to activate.

Cheers,
Vraxor

Vraxor:
hmm, I'm sorry, but I just discovered that this contains a little big bug.

When you use this code the user password will no longer be correct in the mail so it won't really be a lost password mail anymore. I currently ain't have time to figure this out, but maybe this is the start you needed, or maybe there are others out there in the wild world who would like to take a close look at the code and see why it no longer send the password but a strange random code instead.

Cheers,
Vraxor

Vraxor:
Ok, something went wrong with the script and I have no idea what.

I'm such a beginner yet and while I thought I was able to write this little mod I begin to doubt about it now.
Somehow this script changes the password of the user you test it with, so the password becomes a strange random number, in no way this could be meant to happen, but the result was that my admin profile no longer reacted at my password.

I really hope someone could explain to me what went wrong, maybe Jan would like to take a look as I think that the code should be nearly good, just a small error somewhere is causing it to change the password, so anybody wanna help here?

Cheers,
Vraxor

V@no:
wow! Vraxor, it works great! thx alot!
I dont know what are u talking about some bug? no, no way! ;)
actualy it supposed to change password, because of security reason it create new, random password.

yesterday I spent 3 hours trying figure this out, I did same thing what u did, exept I didnt know that I must use "$checkuser[..]" - that why it didnt work for me.
but, here is a little moddification, that will only send activation URL if user has not activated yet, otherwise it will send only username and new password:

in your code add one more "get_user_table_field(", ", "user_level")" so it would looks like this:
--- Code: ---    $sql = "SELECT ".get_user_table_field("", "user_id").get_user_table_field(", ", "user_name").get_user_table_field(", ", "user_password").get_user_table_field(", ", "user_activationkey").get_user_table_field(", ", "user_level")."
--- End code ---

now, change
--- Code: ---        "activation_url" => $script_url."/register.php?action=activate&activationkey=".$checkuser[$user_table_fields['user_activationkey']],
--- End code ---
to this:
--- Code: ---        "activation_url" => (($checkuser[$user_table_fields['user_level']] == 1) ? "You have not activated your accout yet.
           Please click on this link before you can login with your User name and NEW password ".
               $script_url."/register.php?action=activate&activationkey=".$checkuser[$user_table_fields['user_activationkey']] : ""),
--- End code ---

thx again, Vraxor! :D


P.S. duxby, now u can get your activation URL again ;) :D

Navigation

[0] Message Index

[#] Next page

Go to full version