• I was wondering if it was possible to have the form allow to send to multiple users. Like in a contact form, They could choose which department they wanted to contact.

    [sales]
    [general inquries]
    [refunds]

    All three above would have different email address. Would this be possible in making this form manager into a replaceable contact form as well? I also don’t want the email address to be shown of course for spamming reasons.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The best way would be to hook into the ‘fm_form_submission’ action. This is something I added recently. You can use the template here so that updates to form manager don’t overwrite your changes. Just modify the code and upload it as a new plugin.

    So here are the details:
    1) Give the list item a nickname, ’email-list’. For now I’ll assume the list has the items ‘Sales’, ‘General’, ‘Refunds’.
    2) Inside the fm_custom_submission_action function, put the following:

    global $fm_display;
    
    	$formInfo = $args['form'];
    	$postData = $args['data'];
    
    	$subject = fm_getSubmissionDataShortcoded($formInfo['email_subject'], $formInfo, $postData);
    	$message = $fm_display->displayDataSummary('email', $formInfo, $postData);
    	$headers  = 'From: '.fm_getSubmissionDataShortcoded($formInfo['email_from'], $formInfo, $postData)."\r\n".
    				'Reply-To: '.fm_getSubmissionDataShortcoded($formInfo['email_from'], $formInfo, $postData)."\r\n".
    				'MIME-Version: 1.0'."\r\n".
    				'Content-type: text/html'."\r\n";

    This code will load the e-mail settings for the current form, basically just the ‘Subject’ and ‘From’ fields as you have them set in the form editor. You could replace these with whatever you want, but make sure to keep the MIME-Version and Content-type parts in the $headers variable or else you won’t be able to have HTML in the message body.

    3) Add the following to the end of the same function:

    $addressArray = array(
    		'Sales' => "[email protected]",
    		'General' => "[email protected]",
    		'Refunds' => "[email protected]",
    	);
    
    	fm_sendEmail($addressArray[$postData['email-list']], $subject, $message, $headers);

    This is the key part, where you specify an e-mail address to send to based on the value of the ’email-list’ item. Make sure to put a comma after each item in the $addressArray variable like in the example.

    Good luck!

    For your help, your time, your plugin, your work : Mr Campbell Hoffman, THANKS YOU !!!!

    Hi can I please ask which file do we have to add the code in please. Thanks.

    If you read my first post in this thread, I linked to a plugin you can install on your site. The plugin is a template for a custom submission action. That is where the code goes.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Making an Email form with more than one reply:to's’ is closed to new replies.