• Resolved acipriani

    (@acipriani)


    Hi, congratulations for the really useful plugin!
    I can’t customize a form action.
    I have a CPT page generated by another ACF form for hotels, I would like to insert in your template a contact request form so that the email was sent directly to the hotel email included in the first form. I understand that it is a custom action but I can’t make it work

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello!

    I’m glad you enjoy ACF Extended ??

    I will need more informations about what you’re trying to achieve in order to help you. Please provide some detailed data structure. Here is an example of what I understood:

    Page: “Create hotel”
    ——————————–
    ACF Form Front
    — Hotel name (Post title)
    — Hotel logo (Field: logo)
    — Hotel e-mail (Field: email)

    Action: Create new post for post type: hotel, save fields, redirect to hotel single

    Single: “Hotel”
    ——————————–
    ACF Extended Dynamic Form
    — Contact name
    — Contact email
    — Contact message

    Action: Send an email to Hotel field:email with contact infos

    If that’s correct, you should have the email of the hotel as an ACF field on the “Single: Hotel” page. You can retrieve that field dynamically in your Dynamic Form using a custom action and then retrieve it in your “E-mail action” dynamically using {query_var:var} template tag.

    Please confirm this configuration so I can give you a code example.

    Regards.

    Thread Starter acipriani

    (@acipriani)

    Exactly you made the correct example except for the fact that the hotel page does not have a front module but the CPT Hotels are created by the admin in the backen, the front module is only the one for requesting contacts with two actions, one that sends the email to the hotel, the other creates a backend post for the admin to check

    https://paste.pics/f14ee2f1862ff90d2193d31a79dfd477

    https://paste.pics/b9170b4c1a50dbd441a905d6346a83ea

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Sorry for the late answer! Your report reminds me that I should give you the ability to retrieve any ACF field of the current post (or a custom post id) using template tags!

    The current template tag for Dynamic Forms {field:my_field} retrieve the text input (what user has written in the input), not the field in database.

    In your case, you want to retrieve a field saved in the DB of the current post, so it would be nice to have a template tag: {field:hotel_email:current_post}, so you can use it dynamically in your E-mail action. This template tag would be the same as doing get_field('hotel_email') in PHP.

    I’ll add this feature in the the Trello board!

    Meanwhile, you can use an alternative method:

    – Create a new “Custom Action”
    – Call it: get_hotel_email and put it right before your E-mail action
    – In your functions.php file, add the following code:

    add_action('acfe/form/submit/get_hotel_email', 'acfe_form_get_hotel_email', 10, 2);
    function acfe_form_get_hotel_email($form, $post_id){
        
        // Change the field name accordingly
        $hotel_email = get_field('hotel_email', $post_id);
        
        set_query_var('hotel_email', $hotel_email);
        
    }
    

    – In your E-mail action, use the template tag {query_var:hotel_email} in order to dynamically display the hotel email field
    – Done!

    Here is a screenshot of the admin screen: https://i.imgur.com/oId4WWG.jpg

    I’ll let you know when the update comes out for the new template tag, so you can remvove the custom action and directly use it in the E-mail action!

    Note: This alternative method will keep working after the update, it’s just for the sake of comfort.

    have a nice day!

    Regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Mail address from another acf form’ is closed to new replies.