Is it possible to resend email confirmation messages in Moodle 1.8.4?

Is it possible to resend email confirmation messages in Moodle 1.8.4?

by Bill Plumstead -
Number of replies: 9
I am using Moodle 1.8.4 and use "Email-based self-registration" and would like to be able to resend email confirmation messages. I've search the forums and didn't find any information on the subject. If there isn't a way to resend the email confirmation message, is it possible to reconstruct the confirmation link from data in the database? If so, what tables / columns contain the data needed.

Thanks,
Bill Plumstead
Average of ratings: -
In reply to Bill Plumstead

Re: Is it possible to resend email confirmation messages in Moodle 1.8.4?

by Bill Plumstead -
Greetings,

I found that you can reconstruct the confirmation link from data in the database. To reconstruct the URL, the link can be built by using the values of USER.SECRET and USER.USERNAME. Here's how the link would be constructed:

$CFG->WWWROOT/login/confirm.php?data=[USER.SECRET]/[USER.USERNAME]

Where $CFG->WWWROOT is the root of your moodle installation and [USER.SECRET] and [USER.USERNAME] are values from the USER table.

Thanks,
Bill Plumstead



In reply to Bill Plumstead

Re: Is it possible to resend email confirmation messages in Moodle 1.8.4?

by Jon Boggiano -
Where does the [USER.SECRET] come from?
In reply to Bill Plumstead

Re: Is it possible to resend email confirmation messages in Moodle 1.8.4?

by Praveen Parihar -
i am new to moodle ...can anybody pls help me how do i implement this functionality in my moodle site..
In reply to Praveen Parihar

Re: Is it possible to resend email confirmation messages in Moodle 1.8.4?

by Praveen Parihar -
try this piece of code ....


Include this line of code in index.php which u will find in login folder


echo '<a id="btnresend" href="Resendemailmessage.php?'. send_confirmation_email($user). '">Resend Mail</a>';

Attachment Capture.PNG
In reply to Praveen Parihar

Re: Is it possible to resend email confirmation messages in Moodle 1.8.4?

by Dave Emsley -

Hi there,

I need to do this but I cannot find a file called Resendemailmessage.php

Where is it please?


Cheers


Dave

In reply to Dave Emsley

Re: Is it possible to resend email confirmation messages in Moodle 1.8.4?

by Dave Emsley -

As I'm using Moodle 2.9.3 this file doesn't seem to exist, however there is a function within moodlelib.php called setnew_password_and_mail($user) which does this.

I've added the following code to /user/profile.php at the end of the file, under the line: echo $renderer->render($tree);

if (is_siteadmin()) {
    echo "<h2>Sending eMails</h2>";
    echo "email address is:<a href='mailto:".$user->email."'>".$user->email."</a>";
    if ($_GET['sendrenew']==1) {
        if(setnew_password_and_mail($user)) {
            echo "<br>Introductory email re-sent";
        }
        else {
            echo "<br>Introductory email failed to send";
        }
    }
    else {   
        echo "<br><br><a href='profile.php?id=".$user->id."&sendrenew=1'>Resend introductory email</a>";
    } 
}

Couple of things:

  1. I know my coding isn't great.
  2. I read somewhere that is_siteadmin() was being deprecated.


Hope this helps.

Dave Emsley



Average of ratings: Useful (3)
In reply to Dave Emsley

Re: Is it possible to resend email confirmation messages in Moodle 1.8.4?

by Net Vicious -

Thanks Dave, I tested it on 3.0.X and runs perfect.


In reply to Dave Emsley

Re: Is it possible to resend email confirmation messages in Moodle 1.8.4?

by Dave Hope -

Legend! Thanks!! Yes

In reply to Dave Emsley

Re: Is it possible to resend email confirmation messages in Moodle 1.8.4?

by Net Vicious -

Dave, I modified a bit your code to avoid the deprecated is_siteadmin() function.

Only the users who have the capabilities of editing profiles or modifying the site config will see and use the new function.

$sys_context = context_system::instance();

if ( has_capability('moodle/site:config', $sys_context) or has_capability('moodle/user:update', $sys_context) ) {
    echo "<h2>Sending eMails</h2>";
    flush();
    echo "email address is:<a href='mailto:".$user->email."'>".$user->email."</a>";
    if ($_GET['sendrenew']==1) {
        if(setnew_password_and_mail($user)) {
            echo "<br>Introductory email re-sent";
        }
        else {
            echo "<br>Introductory email failed to send";
        }
    }
    else {   
        echo "<br><br><a href='profile.php?id=".$user->id."&sendrenew=1'>Resend introductory email</a>";
    } 
}

unset($sys_context);
Average of ratings: Useful (3)