Support » Plugin: Drag and Drop Multiple File Upload - Contact Form 7 » File list presentation in e-mail message

  • Resolved Patrice

    (@patricevigier)


    Hello,
    On the e-mail message, when you have several file (here 3) links appear one after the others, like below.

    Attached file: htt p://www.xyz.com/wp-content/uploads/wp_dndcf7_uploads/wpcf7-files/blk-1.png, htt p://www.xyz.com/wp-content/uploads/wp_dndcf7_uploads/wpcf7-files/chrome.tif, htt p://www.xyz.com/wp-content/uploads/wp_dndcf7_uploads/wpcf7-files/logo-chrome-2.tif

    Is it possible to have a <br> between each url?
    Thank you
    Patrice

    • This topic was modified 1 year, 4 months ago by Patrice.
    • This topic was modified 1 year, 4 months ago by Patrice.
    • This topic was modified 1 year, 4 months ago by Patrice.
    • This topic was modified 1 year, 4 months ago by Patrice.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Glen Mongaya

    (@glenwpcoder)

    Hello @patricevigier ,

    I see that you are leaving a review, thank you I really appreciate it 🙂

    Now regarding the line break on email it’s default of Contact Form 7, but there’s a way in order to achieve this by adding custom filter.

    Place this code inside your themes/{themename}/functions.php

    add_filter('wpcf7_mail_tag_replaced_mfile*', 'cf7_custom_replaced_tag');
    add_filter('wpcf7_mail_tag_replaced_mfile', 'cf7_custom_replaced_tag');
    
    	function cf7_custom_replaced_tag( $replaced ){
    		if( $replaced && strpos( $replaced, ',' ) ) {
    			$files = array_map('trim', explode(',', $replaced ));
    			$replaced = implode( "\n", $files );
    		}
    		return $replaced;
    	}

    Glen.

    • This reply was modified 1 year, 4 months ago by Glen Mongaya.
    Thread Starter Patrice

    (@patricevigier)

    Hello,
    Thank you for your answer.
    Living a comment was my pleasure, thank you for your work.
    Your code did not work for me, I changed the return to line code. Here it is:

    add_filter('wpcf7_mail_tag_replaced_mfile*', 'cf7_custom_replaced_tag');
    add_filter('wpcf7_mail_tag_replaced_mfile', 'cf7_custom_replaced_tag');
    
    function cf7_custom_replaced_tag($replaced) {
        if ($replaced && strpos($replaced, ',')) {
            $files = array_map('trim', explode(',', $replaced));
            $replaced = implode("<br>", $files);
        }
        return $replaced;
    }

    Sincerely
    Patrice

    Plugin Author Glen Mongaya

    (@glenwpcoder)

    Thanks @patricevigier ,

    I’d like to know if everything is working now so we can close this thread.

    Glen.

    Thread Starter Patrice

    (@patricevigier)

    You can, it is working well.

    Thread Starter Patrice

    (@patricevigier)

    Hello,
    I reopen this thread because since the last update
    File are again in line
    Thank you for your help
    Patrice

    Plugin Author Glen Mongaya

    (@glenwpcoder)

    Can you check if your code inside your theme is still there?

    This snippet : wpcf7_mail_tag_replaced_mfile*, wpcf7_mail_tag_replaced_mfile

    Thread Starter Patrice

    (@patricevigier)

    Hello,

    Yes in the functions.php

    Sincerely

    Plugin Author Glen Mongaya

    (@glenwpcoder)

    Thanks, will test it again.

    Plugin Author Glen Mongaya

    (@glenwpcoder)

    Hello @patricevigier ,

    Sorry for the late reply, Can you try this code?

    add_filter('wpcf7_mail_tag_replaced_mfile*', 'cf7_custom_replaced_tag');
    add_filter('wpcf7_mail_tag_replaced_mfile', 'cf7_custom_replaced_tag');
    
    function cf7_custom_replaced_tag( $replaced ) {
    	if( $replaced && strpos($replaced, ',') ) {
    		$files = array_map('trim', explode(',', $replaced));
    		$html = '';
    		foreach( $files as $file ) {
    			$html .= '<a href="'. esc_url( $file ) .'">'. wp_basename( $file ) .'</a>'."<br>";
    		}
    		return $html;
    	}
    	return $replaced;
    }

    Glen.

    Thread Starter Patrice

    (@patricevigier)

    Hello,
    Thank you very much it works well.
    Take care
    Patrice

    • This reply was modified 1 year, 2 months ago by Patrice.
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘File list presentation in e-mail message’ is closed to new replies.