Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Vanilla send a email to admin when new user signup

edited March 2007 in Vanilla 1.0 Help
Hello friends,

Can anybody help me in this:

I want a mod with which a email is sent (by vanilla installation) to site admin when a new user signup ...BUT in vanilla registration, when it is set that user should be promoted to member role right after signup!

Anybody can suggest something??

Thanks alot for your help :)

Comments

  • My guess is pasting this in an extension would work: (warning: untested code follows)
    function ForceAdminEmail($UserManager) { // Fool Vanilla into thinking that immediate access is not allowed $UserManager->Context->Configuration['ALLOW_IMMEDIATE_ACCESS'] = 0; } $Context->AddToDelegate('UserManager', 'PostRoleAssignment', 'ForceAdminEmail');
  • Hello WallPhone,

    Thanks for the code, but its not working :-(

    After installing, it again set the registration process.. user signup --> Admin approve it (AND no email to admin is sent) BUT i have set it user signup ---> he can login right away

    After removing, everything is back to normal.. but anyways thanks for trying :-D

    any other guess?!? ;-)
  • Bump! Anybody else please... any help?!
  • edited March 2007
    Give this a shot--I'm afraid there is no easy way for me to test this code--but its all been copied from Vanilla anyway.

    function ForceAdminEmail(&$UserManager) { $s = $UserManager->DelegateParameters['SqlBuilder']; $User = $UserManager->DelegateParameters['User']; // Following copied from people/UserManager.php and references to $this were changed to $UserManager $s->Clear(); $s->SetMainTable('User', 'u'); $s->AddJoin('Role', 'r', 'RoleID', 'u', 'RoleID', 'inner join'); $s->AddWhere('r', 'PERMISSION_RECEIVE_APPLICATION_NOTIFICATION', '', 1, '='); $s->AddWhere('u', 'SendNewApplicantNotifications', '', 1, '='); $s->AddSelect(array('Name', 'Email'), 'u'); $Administrators = $UserManager->Context->Database->Select($s, $UserManager->Name, 'CreateUser', 'An error occurred while retrieving administrator email addresses.', 0); // Fail silently if an error occurs while notifying administrators // Get the email body $File = $UserManager->Context->Configuration['LANGUAGES_PATH'] .$UserManager->Context->Configuration['LANGUAGE'] .'/email_applicant.txt'; $EmailBody = @file_get_contents($File); if ($EmailBody && $Administrators) { $EmailBody = str_replace( array( "{applicant_name}", "{applicant_email}", "{application_url}" ), array( $User->Name, $User->Email, ConcatenatePath( $UserManager->Context->Configuration['BASE_URL'], GetUrl($UserManager->Context->Configuration, 'settings.php', '', '', '', '', 'PostBackAction=Applicants') ) ), $EmailBody ); if ($UserManager->Context->Database->RowCount($Administrators) > 0) { $e = $UserManager->Context->ObjectFactory->NewContextObject($UserManager->Context, 'Email'); $e->HtmlOn = 0; $e->ErrorManager = &$UserManager->Context->ErrorManager; $e->WarningCollector = &$UserManager->Context->WarningCollector; $e->AddFrom($User->Email, $User->Name); $AdminEmail = ''; $AdminName = ''; while ($Row = $UserManager->Context->Database->GetRow($Administrators)) { $AdminEmail = ForceString($Row['Email'], ''); $AdminName = ForceString($Row['Name'], ''); if ($AdminEmail != '') $e->AddRecipient($AdminEmail, $AdminName); } $e->Subject = $UserManager->Context->GetDefinition("NewApplicant"); $e->Body = $EmailBody; $e->Send(0); } } }
  • edited March 2007
    I wonder if this works? and if this could be integrated into Notify extension ? somehow?
  • I tried WallPhone's code but it didn't work.. :( maybe stuartbrandon suggestion work! Can some one edit this extension to make it work for this purpose?
This discussion has been closed.