• dacrosby

    (@dacrosby)


    Is there a way to modify the output of fields prior to sending the email?

    For example, [select ddm "1" "2" "3"] is useful for my database but in the confirmation email sent I’d like it to show "1"=>"One", "2"=>"Two", "3"=>"Three".
    Likewise, I have a form where the email field is optional. I want the form value seen to users to be blank, but if they leave it blank when it’s submitted the form fails to send so it needs to be replaced with “not-provided@example.com” or similar on submit.

    I understand the PHP logic to do the string switching, I’m just not sure where to put the code (or which filter to attach to).

    https://wordpress.org/plugins/contact-form-7/

Viewing 1 replies (of 1 total)
  • Thread Starter dacrosby

    (@dacrosby)

    Well, I’m close:

    add_action("wpcf7_posted_data", "wpcf7_modify_this");
    function wpcf7_modify_this($posted_data) {
    	// user doesn't enter an email
    	if ($posted_data['email'] == "")
    		$posted_data['email'] = "not-supplied@example.com";
    	// sets preferred-date radio value to "yes"
    	if ($posted_data['preferred-date'] == "-1")
    		$posted_data['preferred-date'] = "Anytime";
    	return $posted_data;
    }

    The thing to note here is that validation occurs prior to this point.

Viewing 1 replies (of 1 total)

The topic ‘Modify shortcode output’ is closed to new replies.