WordPress.org

Support

Support » Plugins and Hacks » Contact Form 7 » file-uploading-and-attachment

file-uploading-and-attachment

Viewing 4 replies - 1 through 4 (of 4 total)
  • Very close to what I want :

    add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' );
    
    function mycustom_wpcf7_mail_components( $components ) {
    	$components['attachments'][] = 'wp-content/uploads/pdf/r.maharjan.pdf';
    
    	return $components;
    }

    Now I have to collect the PATH of all the pdfs listed in a post. HOW?

    WHY IS THE NOT WORKING?
    The emails doesn’t get send… the sending gif animation loads forever…

    function mycustom_wpcf7_mail_components( $components ){
    
    		$sheets = rwmb_meta( 'brand_sell_sheet', $args = array('type'=>'file' ), $post_id = null );
    			foreach($sheets as $key => $value){
    				$path.= "'".ltrim($value["path"],'public_html/project/hain/')."',";
    			}
    		$attachments = rtrim($path,",");
    
    		$components['attachments']= array($attachments);
    		return $components;
    	}
    
    	add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' );

    This is the closest I could get but still not working.

    add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' );
    	function mycustom_wpcf7_mail_components( $components ){
    		$differentarray = array(); 
    
    		$sheets = rwmb_meta( 'brand_sell_sheet', $args = array('type'=>'file' ), $post_id = null );
    		foreach($sheets as $value){
    			$differentarray[] = ltrim($value["path"],'/home/rajumaha/public_html/project/hain/');
    		}
    		//print_r ($differentarray);
    		$components['attachments']= $differentarray;
    		return $components;
    	}

    I am so tired now… Both functions below result the same. You can see the result here.

    This one works, sends the attachments.Attachments are hard coded.

    /*WORKING*/
    	add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components1' );
    	function mycustom_wpcf7_mail_components1( $components ) {
    		$components['attachments'] = array('wp-content/uploads/2014/02/JASON-Deodorant1.pdf','wp-content/uploads/2014/02/JASON-Dandruff.pdf');
    
    		return $components;
    	}
    /*WORKING*/

    This one does not work. Attachments are dynamically pulled from the custom meta box.

    /*NOT WORKING*/
    	add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components2' );
    	function mycustom_wpcf7_mail_components2( $components ){
    
    		$differentarray = array();
    		$sheets = rwmb_meta( 'brand_sell_sheet','type=file' );
    		foreach ((array)$sheets as $value) {
    			$differentarray[]= ltrim($value["path"],'/home/rajumaha/public_html/project/hain/');
    		}
    		$components['attachments']= $differentarray;
    		return $components;
    	}
    /*NOT WORKING*/

    Somebody please help

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘file-uploading-and-attachment’ is closed to new replies.
Skip to toolbar