mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
Merge branch 'dev-send_reg_approval' into 'dev'
(Re?)enable email to user after account approval See merge request hubzilla/core!2263
This commit is contained in:
@@ -264,9 +264,10 @@ function create_account_from_register($arr) {
|
||||
$result['account']['parent'] = $result['account']['account_id'];
|
||||
}
|
||||
|
||||
$result['success'] = true;
|
||||
|
||||
call_hooks('register_account',$result);
|
||||
if ( send_reg_confirmation_email_from_register($arr['reg_id']) ) {
|
||||
$result['success'] = true;
|
||||
call_hooks('register_account',$result);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -316,6 +317,54 @@ function verify_email_address(string $email): bool {
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send email to user confirming approved registration.
|
||||
*
|
||||
* @param int $reg_id The reg_id of the user (from register table)
|
||||
*
|
||||
* @return bool `true` if the email was sucessfully sent, otherwise `false`.
|
||||
*/
|
||||
function send_reg_confirmation_email_from_register(int $reg_id): bool {
|
||||
|
||||
$register = q("SELECT reg_email, reg_lang FROM register WHERE reg_id = %d", $reg_id);
|
||||
|
||||
if (empty($register)) {
|
||||
logger('send_reg_confirmation_email_from_register: could not find email address for for reg_id ' . $reg_id);
|
||||
return false;
|
||||
} else {
|
||||
logger('send_reg_confirmation_email_from_register: sending confirmation email to ' . $register[0]['reg_email']);
|
||||
}
|
||||
|
||||
if(strlen($register['reg_lang'])) {
|
||||
push_lang($register['reg_lang']);
|
||||
} else {
|
||||
push_lang('en');
|
||||
}
|
||||
|
||||
$email_msg = replace_macros(get_intltext_template('register_approved_eml.tpl'), array(
|
||||
'$sitename' => Config::Get('system','sitename'),
|
||||
'$siteurl' => z_root(),
|
||||
'$email' => $register[0]['reg_email'],
|
||||
));
|
||||
|
||||
$res = z_mail(
|
||||
[
|
||||
'toEmail' => $register[0]['reg_email'],
|
||||
'messageSubject' => sprintf( t('Registration approved at %s'), Config::Get('system','sitename')),
|
||||
'textVersion' => $email_msg,
|
||||
]
|
||||
);
|
||||
|
||||
pop_lang();
|
||||
|
||||
if ($res) {
|
||||
return true;
|
||||
} else {
|
||||
logger('send_reg_confirmation_email_from_register: failed to send confirmation email to ' . $register[0]['reg_email']);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function send_reg_approval_email($arr) {
|
||||
|
||||
|
||||
15
view/lang/en/register_approved_eml.tpl
Normal file
15
view/lang/en/register_approved_eml.tpl
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
Congratulations!
|
||||
|
||||
Your account at {{$sitename}} has been approved. Log in using the
|
||||
login details you provided when signing up.
|
||||
|
||||
Site Location: {{$siteurl}}
|
||||
Login: {{$email}}
|
||||
Password: (the password which was provided during registration)
|
||||
|
||||
Thank you and welcome to {{$sitename}}.
|
||||
|
||||
Sincerely,
|
||||
{{$sitename}} Administrator
|
||||
|
||||
Reference in New Issue
Block a user