• Resolved bygchyll

    (@bygchyll)


    I’m working on a directory where users can submit their listings on the frontend through a Forminator post data, with additional custom fields mapped to ACF fields. When the submissions are displayed on the listings page, people should be able to click each listing for more details and then contact the listing owners through a contact form. Is it possible to get a contact form (one Forminator contact form) to dynamically send emails to the separate emails collected during the submission stage, by referencing the ACF email address field? So when someone fills a contact form after selecting a listing for further details, that contact form should be sent to that email linked to that particular listing.

    If you have the time, kindly refer to this video that offers a similar solution: https://www.youtube.com/watch?v=PxLqRFhSEhQ

    Any help would be greatly appreciated. Thanks in advance.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @bygchyll

    I hope you are doing well today.

    This should be possible with pre-populate fields:
    https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#pre-populate-form-field-values

    How this should work:

    On the list template page, you will place 1st form which will read the post title and email of the owner. With that one form will handle all offers. The issue here is that we need on that page owner email and read it somehow. If that is sorted we can use the above pre-populate and after submission end user will be redirected to a new page where 2nd form will be located. This 2nd form will already have filled title of this offer (post title) and email + additional fields like textarea where this end user will be able to add some additional notes.

    Second scenario could be similar to 1st one, but this time without going to 2nd form and simply read all data on list page and autofill email and title.

    I pinged our SLS Team if that will be possible and in what way you will need to put that owner email on list page. We will post an update here as soon as more information is available.

    Kind Regards,
    Kris

    Thread Starter bygchyll

    (@bygchyll)

    Hello Kris,

    Thanks for this feedback. Will give this a shot when I’m able to. Will also wait for any other feedback as and when it becomes available.

    Kind regards

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @bygchyll ,

    Please check those code snippets, they might help you with your query:

    add_filter( 'forminator_field_hidden_field_value', 'wpmudev_populate_author_email_field', 10, 4 );
    function wpmudev_populate_author_email_field( $value, $saved_value, $field, $hidden_field ){
    	if ( 'custom_value' == $saved_value && '{author_mail}' == $value ) {        		
    		$value = sanitize_text_field( get_the_author_meta('user_email') );
    	}
    	return $value;
    }

    This one is for use in a hidden field
    https://monosnap.com/file/bfaStFyCmfCtmcxmAsXpEcMmFNHh8g with {author_mail}.
    get_the_author_meta('user_email') – this part where you grab the ACF email address field.

    And then this snippet:

    add_filter( 'forminator_prepared_data', 'wpmudev_update_hidden_field_val_twin', 10, 2 );
    function wpmudev_update_hidden_field_val_twin( $prepared_data, $module_object ){
        $form_ids = array(6); //Please change the form ID
    	if ( !in_array( $module_object->id, $form_ids ) ) {
    		return $prepared_data;
    	}
        
        foreach ( $prepared_data as $key => $value ) {
            if ( strpos( $key, 'hidden-1' ) !== false ) {
                $prepared_data[$key] = sanitize_text_field( $_POST[$key] );
            }
        }
    
    	return $prepared_data;
    }
    
    add_action( 'forminator_custom_form_submit_before_set_fields', 'wpmudev_change_hidden_field_data_twin', 10, 3 );
    function wpmudev_change_hidden_field_data_twin( $entry, $module_id, $field_data_array ) {
        $form_ids = array(6); //Please change the form ID
         if ( !in_array( $module_id, $form_ids ) ) {
    		return;
          }
        
        foreach ( $field_data_array as $key => $value ) {
            if ( strpos( $value['name'], 'hidden-1' ) !== false ) {
                Forminator_CForm_Front_Action::$info['field_data_array'][$key]['value'] = sanitize_text_field( $_POST[$value['name']] );
            }
        }
    
    }

    Find lines $form_ids = array(6); //Please change the form ID and change 6 to your form’s ID.

    Those code snippets can be used as mu-plugin https://premium.wpmudev.org/docs/getting-started/download-wpmu-dev-plugins-themes/#installing-mu-plugins

    kind regards,
    Kasia

    Thread Starter bygchyll

    (@bygchyll)

    Hello Kasia,

    Thanks for everything. Really appreciate it. Will try out the code as suggested.

    Kind regards

    Thread Starter bygchyll

    (@bygchyll)

    Hi,

    How do I find the form ID?

    Find lines?$form_ids = array(6); //Please change the form ID?and change 6 to your form’s ID.

    Thanks

    Plugin Support Zafer – WPMU DEV Support

    (@wpmudevsupport15)

    Hi @bygchyll,

    I hope you are doing well today!

    You can find your Form’s ID in various ways;

    1-Forminator->Forms->Hover on Edit button and you will see the ID at the bottom left of your browser.
    2-Forminator->Forms->Copy shortcode which will include your Form’s ID
    3-Forminator->Forms->Click on Edit button and you will see the ID at your addressbar in URL ending with ..&id=yourid

    Please let us know if you need further help or clarification.

    Kind regards,
    Zafer

    Thread Starter bygchyll

    (@bygchyll)

    Thanks very Zafer. Will check this out and let you know.

    Kind regards

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @bygchyll ,
    ?
    We haven’t heard from you for several days now, so it looks like you no longer need our assistance.
    ?
    Feel free to re-open this topic if needed.
    ?
    Kind regards
    Kasia

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Dynamically Submit Contact Form to ACF Email Address’ is closed to new replies.