• Resolved antoinelrx

    (@antoinelrx)


    Hi,

    I created this function to add a vcf to an email. It works if I try with a png file. But it is not working with vcf and I can’t figure out why. Do you have any idea ? I’m 100% sure the file is in the folder, I can access it with other functions.

    add_filter('acfe/form/submit/email_args/action=mail-prospect', 'user_vcf', 10, 3);
    function user_vcf($args, $form, $action) {
        $ecard_id = get_the_ID();
        $random_slug = get_field('random_slug', $ecard_id);
        
        $sourceFilePath = trailingslashit(ABSPATH) . '/f/contact/' . $random_slug . '/' . $random_slug . '.vcf';
        $destinationFilePath = trailingslashit(ABSPATH) . '/f/prospects/' . $random_slug . '.vcf';
        
        // Copy the file
        if (copy($sourceFilePath, $destinationFilePath)) {
    
            //WORKS $args['attachments'] = array(trailingslashit(ABSPATH) . '/f/prospects/logo-ecard.png'); 
            //DO NOT WORK $args['attachments'] = array(trailingslashit(ABSPATH) . '/f/prospects/cmdjqi.vcf'); 
            $args['attachments'] = array($destinationFilePath);
            
           //WORKS unlink($destinationFilePath);
        }
          
        return $args;
    }
Viewing 1 replies (of 1 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    Any kind of file type can be attached to an email, as long as it is permitted by wp_mail() (which is the function used by ACFE behind the scene to send emails).

    I would recommend to double check your code, and log data using acf_log() to make sure everything is in order during the form submission.

    You’ll find an extended guide on how to debug WP/ACFE here if needed.

    Hope it helps!

    Regards.

Viewing 1 replies (of 1 total)
  • The topic ‘VCF as attachment’ is closed to new replies.