• Resolved helppawz1

    (@helppawz1)


    Hi.

    I have a form which creates post data when submitted. I want to send a copy of some of the information in this form to the person who submitted the form. I want to include the post content and the featured image. The only way I can see to do this is to add {postdata-1} to the email template, but this also includes the custom fields which I don’t want. How do I only include the post content and featured image?

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello @helppawz1 !

    I hope you’re having a great week!

    It should be possible to achieve using a custom snippet that will filter out the unnecessary data. I’ve already asked our Second Line Support team to check the case and prepare such snippet for you – we’ll share it here as soon as it becomes available.

    Warm regards,
    Pawel

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @helppawz1,

    Please try this snippet and see whether it works:

    <?php
    
    add_filter( 'forminator_replace_form_data', 'wpmudev_send_post_data_email', 10, 3 );
    function wpmudev_send_post_data_email( $content, $data, $original_content ){
    	if( $data['form_id'] != 361 ){
    		return $content;
    	}
    
    	if( strpos( $content, '{post-content}' ) !== false ){
    		if( isset( $data['postdata-1'] ) ){
    			if( isset( $data['postdata-1']['post-content'] ) ){
    				$content = str_replace( '{post-content}', $data['postdata-1']['post-content'], $content );
    			}
    		}
    	}
    
    	if( strpos( $content, '{post-image}' ) !== false ){
    		if( isset( $data['postdata-1'] ) ){
    			if( isset( $data['postdata-1']['post-image'] ) ){
    				$content = str_replace( '{post-image}', wp_get_attachment_image( $data['postdata-1']['post-image']['attachment_id'], 'full' ), $content );
    			}
    		}
    	}
    
    	return $content;

    You’ll have to edit the following line in the above code to your form ID:

    	if( $data['form_id'] != 361 ){
    

    Suppose the from ID is 123, the above line will change to:

    	if( $data['form_id'] != 123 ){
    

    The snippet uses {post-content} and {post-image} for content and images. The above snippet can be implemented using mu-plugins.

    Please check this link on how to implement the above code as a mu-plugins:
    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Kind Regards,
    Nithin

    Thread Starter helppawz1

    (@helppawz1)

    That works, thank you so much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Remove Custom Fields from Email Notification’ is closed to new replies.