Dynamically Changing From fields
-
Hi, I have created a contact form (no plugin) and want to send an email with the from name and email set to something that was entered in the form, but I am sending other emails on a different section of my website from the website itself, and that works fine. I have tried using the $opts associative array which will change the options on the wp-admin settings, but only for future emails, the one being sent still has the master settings. My code is as below.
send-message.php$opts = get_option( 'swpsmtp_options' ); $previousFrom = $opts['from_name_field']; $previousFromEmail = $opts['reply_to_email']; $opts['from_name_field'] = $fromName; $opts['reply_to_email'] = $fromEmail; update_option( 'swpsmtp_options', $opts );
and then after wp_mail(…); I reset them.
$opts['from_name_field'] = $previousFrom; $opts['reply_to_email'] = $previousFromEmail; update_option( 'swpsmtp_options', $opts );
As I said above this is changing the values on the settings screen, which means it will work for further emails. Am I changing the options at the right time, or do I need to do it sooner somewhere. Also if more than one person on different clients do this at the same time then surely there will also be a problem, I just want to do it for this session, single email. Thanks
- The topic ‘Dynamically Changing From fields’ is closed to new replies.