- Posts: 11639
- Thank you received: 2737
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Separate Send from and Reply to email addresses
- holch
- Offline
- LimeSurvey Community Team
kclingerman needed a quick solution and this is what he found. Might there be a better solution? Obviously, as you have shown. But we should be happy that he was giving back to the community, most people here are only taking.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
- DenisChenu
- Offline
- LimeSurvey Community Team
- Posts: 13597
- Thank you received: 2487
Updating LimeSurvey core are always a bad solution.holch wrote: Denis, not everyone is as firm with the plugin system for Limesurvey as you are.
kclingerman needed a quick solution and this is what he found. Might there be a better solution? Obviously, as you have shown. But we should be happy that he was giving back to the community, most people here are only taking.
And here : there are sample clear and easy to adapt.
LimeMailer : 799 lines
mailSenderToFrom : 48 lines
We have an extandable system : we must give good advice on forum not broken advice ... that potentially broke update ...
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
- holch
- Offline
- LimeSurvey Community Team
- Posts: 11639
- Thank you received: 2737
We have an extandable system : we must give good advice on forum not broken advice ... that potentially broke update ...
I agree. But your post doesn't sound like "good advice" but like a grumpy old grandpa...
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
- kclingerman
- Topic Author
- Offline
- New Member
- Posts: 8
- Thank you received: 1
Thank you for providing a better way for people to accomplish this in the future Denis!
I will try to see if I can get together a plugin which does exactly what I want and share it with the community. I am no expert in PHP but I hope I can contribute!
- DenisChenu
- Offline
- LimeSurvey Community Team
- Posts: 13597
- Thank you received: 2487
Otherwise: I criticize the method, not the person. It also happens to me to write stupid and silly things.
For the plugin :
Start with mailSenderToFrom : update it in a new directory inside ./plugins
mailAnswerTo, rename the php file to mailAnswerTo.php
find mailSenderToFrom in the php file to mailAnswerTo, same in config file.
Remove the code here:
github.com/LimeSurvey/LimeSurvey/blob/d6...erToFrom.php#L40-L45
And replace by (for example)
$limeMailer->AddReplyTo(App()->getConfig('siteadminemail'));
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
- kclingerman
- Topic Author
- Offline
- New Member
- Posts: 8
- Thank you received: 1
Can you direct me to some documentation on adding settings to a survey? I would like to be able to set the reply-to address per survey.
- kclingerman
- Topic Author
- Offline
- New Member
- Posts: 8
- Thank you received: 1
I need some advice on this, I am having a lot of trouble with object oriented php lol. In the below plugin storing the plugin settings is fine, but I don't know how to get that into the $limeMailer->AddReplyTo function. Can you please let me know what I am doing wrong?
Thank you!
<?php 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() { $pluginsettings = $this->getPluginSettings(true); $event = $this->getEvent(); $iSurveyID=$event->get('iSurveyID'); $event->set("surveysettings.{$iSurveyID}", 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://manual.limesurvey.org/BeforeTokenEmail */ public function beforeEmail() { $emailsmtpuser = Yii::app()->getConfig('emailsmtpuser'); if(empty($emailsmtpuser)) { return; } $limeMailer = $this->getEvent()->get('mailer'); $limeMailer->AddReplyTo($this->get('customReplyTo', 'Survey', $event->get('survey'))); $this->getEvent()->set('updateDisable',$updateDisable); } }
- DenisChenu
- Offline
- LimeSurvey Community Team
- Posts: 13597
- Thank you received: 2487
See : manual.limesurvey.org/BeforeSurveyEmail
After
$this->get('customReplyTo', 'Survey', $surveyId);
If you need a global one $this->get('customReplyTo');
finally something like this
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; } $limeMailer = $this->getEvent()->get('mailer'); $limeMailer->AddReplyTo($customReplyTo); }
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
- DenisChenu
- Offline
- LimeSurvey Community Team
- Posts: 13597
- Thank you received: 2487
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
- kclingerman
- Topic Author
- Offline
- New Member
- Posts: 8
- Thank you received: 1
The only issue I see now is when the plugin customToken is enabled, my customReplyTo plugin does not show up under the "Simple plugins" menu, only the customToken setting is shown. Is this an issue with limesurvey, or how the plugin was created?
Here is the full source as I am currently using it:
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() { $pluginsettings = $this->getPluginSettings(true); $event = $this->getEvent(); $iSurveyID=$event->get('iSurveyID'); $event->set("surveysettings.{$iSurveyID}", 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://manual.limesurvey.org/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; } $limeMailer = $this->getEvent()->get('mailer'); $limeMailer->AddReplyTo($customReplyTo); } }
- DenisChenu
- Offline
- LimeSurvey Community Team
- Posts: 13597
- Thank you received: 2487
Unsure,kclingerman wrote: The only issue I see now is when the plugin customToken is enabled, my customReplyTo plugin does not show up under the "Simple plugins" menu, only the customToken setting is shown. Is this an issue with limesurvey, or how the plugin was created?
can be a LimeSurvey issue.
You mean you have only one Simple plugin settings shown ?
I think there are an issue in you code.
$oEvent->set("surveysettings.{$this->id}", array(
and not
$event->set("surveysettings.{$iSurveyID}", array(
Because you muts add settings for YOUR plugin.
It's an issue in the core plugin
github.com/LimeSurvey/LimeSurvey/blob/4c.../customToken.php#L85
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
- DenisChenu
- Offline
- LimeSurvey Community Team
- Posts: 13597
- Thank you received: 2487
github.com/LimeSurvey/LimeSurvey/commit/...511f13ad6848efb3eefe
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.