New register user notification to admin's email

New register user notification to admin's email

by runers N -
Number of replies: 21
Hello!

I did'nt recieve notifications of new registrations. How to solve this problem. Please help. Thanks.Широкие глаза
Average of ratings: -
In reply to runers N

Re: New register user notification to admin's email

by E. L. Cooper -
There is no notification to admin at this time but here is some documentation on a hack to do it. YMMV As always save an unedited copy of the file you will be changing in case there is an issue.
In reply to E. L. Cooper

Re: New register user notification to admin's email

by E. L. Cooper -

my hyper link disappeared so here it is again http://docs.moodle.org/en/Administration_hacks and it is number 2 on the list

In reply to E. L. Cooper

Re: New register user notification to admin's email

by runers N -
Hi Cooper!
Thank you for your time.

I checked this hack. It does not work with 1.9+. I did not find in the code mentioned lines. Look...
----------------

Send a duplicate of the registration email to the administrator

In /lib/moodlelib.php, search for the function send_confirmation_email (around line 3629 in 1.8.4+). At the end of the function there is a line that reads (2):

 return email_to_user($user, $from, $subject, $message, $messagehtml);

Just before that line, add a line like this:

 email_to_user($from, $from, $subject, $message, $messagehtml);
-------------------
Do you know how to change this code?
In reply to runers N

Re: New register user notification to admin's email

by John Barr -

I have a similar problem:

I found the required text in line 4379:

    $message = get_string('newusernewpasswordtext', '', $a);

    $subject  = format_string($site->fullname) .': '. get_string('newusernewpasswordsubj');

    return email_to_user($user, $supportuser, $subject, $message);

}

It is not quite the same - so I was not quite sure what to do.

I also want the Emails sent to another address as well as my own but I am unsure how to do this.

Help please

In reply to John Barr

Re: New register user notification to admin's email

by E. L. Cooper -
Your right the way the string calls html is very different. I'll try a things and see what I can do for an answer.
In reply to E. L. Cooper

Re: New register user notification to admin's email

by John Barr -

I changed $user to $supportuser and it appears to have worked.

I still can't get it to send the Email to another person...

In reply to John Barr

Re: New register user notification to admin's email

by E. L. Cooper -
John I am pretty sure your system will not send the mail to the registering person the way you did it. Did you test that? Actually I think I figured out how to make it mail someone else without changing the default support email in moodle. What ever role the has create a duplicate role with another name (only the person who gets this email should be assigned the role) then put newroll (whatever you name the new roll) or newrolluser into the spot where supportuser would go.
In reply to John Barr

Re: New register user notification to admin's email

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If you want to send the same email to another additional address, you can add the following lines:

$otheruser = new object(); $otheruser->firstname = 'User Firstname'; $otheruser->lastname = 'User Lastname'; $otheruser->email = 'user@some.email.domain'; email_to_user($otheruser, $supportuser, $subject, $message, $messagehtml);

before the line that reads:

return email_to_user($user, $supportuser, $subject, $message, $messagehtml);

If you want to send it to several people, simply copy & paste the above lines as many times as needed.

Saludos. Iñaki.

Average of ratings: Useful (1)
In reply to Iñaki Arenaza

Re: New register user notification to admin's email

by E. L. Cooper -

That'll work and I think it is a more flexable solution than the well documented one as, (for example) it would allow the school bookkeeper to recieve a notification.

It is noteworthy for the less than completely familiar with php fill in between the ' and' 

    $otheruser = new object();
    $otheruser->firstname = 'User Firstname';
    $otheruser->lastname = 'User Lastname';
    $otheruser->email = 'user@some.email.domain';
    email_to_user($otheruser, $supportuser, $subject, $message, $messagehtml);
 
    return email_to_user($user, $supportuser, $subject, $message, $messagehtml);

In reply to E. L. Cooper

Re: New register user notification to admin's email

by John Barr -

Thanks - this is just what I needed.

John

In reply to E. L. Cooper

Re: New register user notification to admin's email

by Turki h -

Hi,

I used the folloinwg code and it works fine. However, the admin is reciving un-formatted version of the email (php code rather than HTML). Even when i insert the the mailformat =1 line

Here is my code:

$user->mailformat = 1;  // Always send HTML version as well
$otheruser->mailformat = 1;  // Always send HTML version as well

$otheruser = new object();
$otheruser->firstname = 'my fisrt name';
$otheruser->lastname = 'my last name';
$otheruser->email = 'sindbad1200@gmail.com';
email_to_user($otheruser, $supportuser, $subject, $message, $messagehtml);

return email_to_user($user, $supportuser, $subject, $message, $messagehtml);

 

any help please

Turk

In reply to Turki h

Re: New register user notification to admin's email

by Oleg Kosarev -

hello How to Moodle 1.9.15 + create one admin notification of new registered users. tried all the methods have not worked no more than one ...

In reply to Iñaki Arenaza

Re: New register user notification to admin's email

by John Barr -

Thanks Saludos - just what I needed.

John

In reply to John Barr

Re: New register user notification to admin's email

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You're welcome. Just a little detail: 'saludos' is the Spanish word for 'greetings'. Iñaki is my real name wink

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: New register user notification to admin's email

by B Beals -
for 'otheruser', is that where we input the new role name, or does that stay simply as it is when I input in the moodlelib.php
In reply to B Beals

Re: New register user notification to admin's email

by E. L. Cooper -

it stays as is and you put the person who you wish to cc into the places where the code is red

Average of ratings: Useful (1)
In reply to E. L. Cooper

Re: New register user notification to admin's email

by B Beals -
Cool!

Thank you E.L. for your endless contributions!
In reply to E. L. Cooper

תשובה ל: Re: New register user notification to admin's email

by shuki vaknin -
Hello! And thanks for all your support.
I am just asking is there a way to send a formatted notice with new user details to the admin?

Thanks alot!
In reply to shuki vaknin

Re: תשובה ל: Re: New register user notification to admin's email

by E. L. Cooper -
Tje short answer is yes but only if you want to hack the code as seen here http://moodle.org/mod/forum/discuss.php?d=120482&parent=531664
In reply to E. L. Cooper

תשובה ל: Re: תשובה ל: Re: New register user notification to admin's email

by shuki vaknin -
Thanks a lot for the replay!

I've been doing it before, but I was asking for a more elegant way. I don't want the confirmation email, I want it to email me the details the user has been inserted.

Thanks a lot for support! Your replay is greatly appreciated!
In reply to E. L. Cooper

Re: תשובה ל: Re: New register user notification to admin's email

by S. Ali -

Hello,

I'm wondering if this solution also works in Moodle 2.7?

I've tried implementing it but the email isn't being received by the "otheruser".

Any help would be greatly appreciated.

Many thanks.