• Resolved disturbed-pixel

    (@disturbed-pixel)


    Hi,

    Just found your plugin and i’m excited to start using it.

    However, i am just playing about at the moment, but i’d like to send an email and include a link to the new post it will create for me.

    I might be being blind, but i cannot see any quick and easy way to add this.

    Thanks

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

    (@hwk-fr)

    Hello,

    The problem is a bit more complexe than it looks. The thing is, with ACF Extended Dynamic Forms you can create as many actions as you want for each form submission. Which means you can theorically create “150 new posts” in one single submission and then at the end “Send an email”.

    In this case, it’s difficult to give you a tool in the UI to choose which “post URL” should be included in the last email.

    You could send a custom mail using PHP only when your “New post” action get completed you could using the following code:

    
    add_action('acfe/form/submit/post/form=my-form', 'my_form_post_save', 10, 5);
    function my_form_post_save($post_id, $type, $args, $form, $action){
        
        /**
         * @int     $post_id    The targeted post ID
         * @string  $type       Action type: 'insert_post' or 'update_post'
         * @array   $args       The generated post arguments
         * @array   $form       The form settings
         * @string  $action     The action alias name
         */
    
        $created_post_id = $post_id;
        
        // wp_mail() ...
        
    }
    

    BTW, in a future update I plan to add {query_var:my_var} template tag that will be available in the email action. This way you could set_query_var() during the post creation, and re-use it directly in the “e-mail action” UI ??

    Regards.

    Thread Starter disturbed-pixel

    (@disturbed-pixel)

    Hi @hwk-fr

    Thanks! Looking forward to your update, that would be really useful template tags.

    I only want to send 1 email per form completion for the post created.

    So at present i would have to create an action/function per form “form=my-form-slug-name” and use wp_mail to send the notification email?

    Can i also grab some of the form values in this? using {field:field_key} etc

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    I wanted to reply earlier, but I was very busy. Actually, if you use PHP hooks to send a custom email using wp_mail() in acfe/form/submit/post/form=my-form you would have to use get_field('my_field') instead of template tags {field:my_field} (like in the UI).

    The good news is that the latest ACF Extended Update 0.8.4.6 added the custom query var functionalities in Dynamic Forms I was talking about in the previous answer ??

    You can now retrieve the data from a post you created in a previous action, and display a link in your e-mail UI, dynamically.

    Here is a how-to:

    Create a “Post Action” which will create the post of your choice. Set a custom action name, for example “my-post”. This will open a new setting “Query var”. Enable this new setting.

    Create an “E-mail Action”. Inside the email UI, you can now use the following template tag to retrieve your post link: {query_var:my-post:permalink}.

    Here is a screenshot: https://i.imgur.com/uioV95V.png

    Hope it helps ??

    Regards.

    Thread Starter disturbed-pixel

    (@disturbed-pixel)

    Had to get my head around it first, but Fantastic! yep it works seamlessly.

    Really appreciate your help and your awesome plugin! I have a few other questions, but i’ll make a new thread.

    Thanks again!

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    I’m glad it now works as you wanted! If you enjoy this plugin, feel free to submit a review, it always helps and it’s much appreciated ??

    Have a nice day!

    Regards.

    Thread Starter disturbed-pixel

    (@disturbed-pixel)

    Thanks!! done ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘In the email, how to add a link to the new post created’ is closed to new replies.