• Resolved jssbth

    (@jssbth)


    Great plugin!

    I’m running into a problem with emailing dynamic attachments from a repeater field. I have three ACF Image Aspect Ratio Crop fields in a repeater field (3rd party plugin). I’d like to send the cropped version of the image as an attachment in an email, but it does not work.

    The only way I can get anything from these fields is by using {fields}, which gives me a link to every version of the file in the body of the email.

    I’m not a developer, just like to tinker on my own sites. Any help or direction you can provide would be greatly appreciated.

    • This topic was modified 2 years, 6 months ago by jssbth.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    I’m not sure about how the ACF Image Aspect Ratio Crop field works, but you can inject the attachments of your choice on any ACFE Form Email Action using the acfe/form/submit/email_args hook. See documentation.

    Just make sure that you correctly set the image file path. Usage example:

    add_filter('acfe/form/submit/email_args/action=my-email', 'my_form_email_args', 10, 3);
    function my_form_email_args($args, $form, $action){
    
        // Add file to attachments
        $args['attachments'] = array('/path/to/file.jpg');
        
        // return
        return $args;
        
    }
    

    If your files are inside a repeater, then you’ll have to retrieve them using the native have_rows(): the_row() logic (See documentation), and inject them in the email arguments. Usage example:

    add_filter('acfe/form/submit/email_args/action=my-email', 'my_form_email_args', 10, 3);
    function my_form_email_args($args, $form, $action){
        
        // initialize files
        $files = array();
        
        if(have_rows('my_repeater')):
            while('my_repeater'): the_row();
                
                // get image sub field
                $my_image = get_sub_field('my_image');
                
                // add my image to files
                $files[] = $my_image;
        
            endwhile;
        endif;
    
        // Add files to attachments
        $args['attachments'] = $files;
        
        // return
        return $args;
        
    }
    

    Hope it helps!

    Have a nice day!

    Regards.

    Thread Starter jssbth

    (@jssbth)

    Thank you for the reply and the update.

    I wanted to add that I don’t think the problem with dynamic attachments is unique to the way the 3rd party plugin works. The normal image field doesn’t work either. I believe it’s due to the field being inside a repeater field.

    Edited to add: I know it may not be a priority, but it would great if this worked on repeaters too for us no/low code users.

    • This reply was modified 2 years, 6 months ago by jssbth.
    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Absolutely, this feature was designed for top level fields and not sub fields in Repeater & Flexible Content since those would become virtually unlimited (possible sub field of a sub field of a sub field…). That would add a lot more complexity in the current system. It may come in the future, but for now this kind of complex setup require to use available hooks unfortunately.

    Did you manage to make it work with the ACF Image Crop Field?

    Regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Email Attachment from Repeater’ is closed to new replies.