Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions LoginRegister.module
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @property array $registerFields Field names to show in registration form.
* @property array $profileFields Field names to show in profile form.
* @property array $features
* @property string $emailFrom Send emails from this address
*
* HOOKABLE METHODS
* ----------------
Expand Down Expand Up @@ -74,6 +75,7 @@ class LoginRegister extends WireData implements Module, ConfigurableModule {
$this->set('registerFields', array('name', 'email', 'pass'));
$this->set('profileFields', array('name', 'pass'));
$this->set('features', array('login', 'register', 'profile'));
$this->set('emailFrom', '');

parent::__construct();
}
Expand Down Expand Up @@ -238,6 +240,19 @@ class LoginRegister extends WireData implements Module, ConfigurableModule {
}
return $name;
}

/**
* Get address to send emails from
*
* @return string
*
*/
protected function getEmailFrom() {
$emailFrom = $this->emailFrom;
if(empty($emailFrom)) $emailFrom = $this->wire('config')->adminEmail;
if(empty($emailFrom)) $emailFrom = 'noreply@' . $this->wire('config')->httpHost;
return $emailFrom;
}

/**
* Main login flow control, handles all input/output for this module
Expand Down Expand Up @@ -675,6 +690,7 @@ class LoginRegister extends WireData implements Module, ConfigurableModule {
$confirmURL = $this->wire('page')->httpUrl() . "?register_confirm=" . urlencode($confirmCode);

$mail = new WireMail();
$mail->from = $this->getEmailFrom();
$mail->subject(sprintf($this->_('Confirm account at %s'), $config->httpHost));
$mail->to($email);

Expand Down Expand Up @@ -1104,6 +1120,13 @@ class LoginRegister extends WireData implements Module, ConfigurableModule {

$hasForgot = $this->modules->isInstalled('ProcessForgotPassword');

/** @var InputfieldEmail $f */
$f = $this->wire('modules')->get('InputfieldEmail');
$f->attr('name', 'emailFrom');
$f->label = $this->_('Email address to send messages from');
$f->attr('value', $this->emailFrom);
$inputfields->add($f);

/** @var InputfieldCheckboxes $f */
$f = $this->modules->get('InputfieldCheckboxes');
$f->attr('name', 'features');
Expand Down