- Posts: 5
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
Please Log in to join the conversation.
class CustomReplyTo extends PluginBase { protected $storage = 'DbStorage'; static protected $description = 'Set reply-to address'; static protected $name = 'CustomReplyTo'; public function init() { $this->subscribe('beforeEmail','beforeEmail'); $this->subscribe('beforeSurveyEmail','beforeEmail'); $this->subscribe('beforeTokenEmail','beforeEmail'); // Provides survey specific settings. $this->subscribe('beforeSurveySettings'); // Saves survey specific settings. $this->subscribe('newSurveySettings'); } public function beforeSurveySettings() { $event = $this->getEvent(); $event->set("surveysettings.{$this->id}", array( 'name' => get_class($this), 'settings' => array( 'customReplyTo' => array( 'type' => 'string', 'label' => 'Custom Reply-To:', 'current' => $this->get('customReplyTo', 'Survey', $event->get('survey')) ) ) )); } /** * Save the settings */ public function newSurveySettings() { $event = $this->getEvent(); foreach ($event->get('settings') as $name => $value) { $this->set($name, $value, 'Survey', $event->get('survey')); } } /** * Set From and Bounce of PHPmailer to siteadminemail * @link https://www.limesurvey.org/manual/BeforeTokenEmail */ public function beforeEmail() { /* Global one (if you have a global settings array */ $customReplyTo = $this->get('customReplyTo'); /* get the current survey id */ $surveyId = $this->getEvent()->get('survey'); // Survey id as integer if($surveyId) { /* Maybe use globalk is empty ( == "") */ $customReplyTo = $this->get('customReplyTo', 'Survey', $surveyId); } if(empty($customReplyTo)) { return; } $customReply = LimeExpressionManager::ProcessString($customReplyTo); $limeMailer = $this->getEvent()->get('mailer'); $limeMailer->AddReplyTo($customReply); } }
Please Log in to join the conversation.