Attachment in email after submission

Support MB Frontend Submission Attachment in email after submissionResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #36389
    synchrosynchro
    Participant

    One of my fields in a front-end form is "upload file" which adds an attachment to the form.
    I successfully created an email notification upon the form submission with all the other fields but I can't pass that attachment. I simply don't know how to get that attachment. Can you help me please?

    #36413
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can try to use the action hook rwmb_frontend_after_process to get the attachment URL (field value) based on the post ID and included in the email content. For example:

    add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) {
        if ( 'my-meta-box' === $config['id'] ) {
            $files = rwmb_meta( 'my_field_id', '', $post_id );
        
            wp_mail( '[email protected]', 'New submission', 'A new post has been just submitted.' . $files[0]['url'] ); //or change it to $files['url'] if you have only one attachment
    
            wp_safe_redirect( 'thank-you' );
            die;
        }
    }, 10, 2 );

    Refer to the documentation https://docs.metabox.io/fields/file-upload/#template-usage
    https://docs.metabox.io/extensions/mb-frontend-submission/#form-hooks

    #36503
    synchrosynchro
    Participant

    Thank you for your answer Long, I succeeded to return the file url 🙂 after like 2 hours of fight...
    I learn with you a lot 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.