Results 1 to 4 of 4

Thread: How to add custom fields to email notification

  1. #1
    dikiyforester's Avatar
    Join Date
    Oct 2011
    Location
    Russian Federation
    Posts
    2,229
    Thanks
    89
    Thanked 593 Times in 491 Posts

    How to add custom fields to email notification

    Hi all!!!!!

    Here I will start a series of Tutorials how to add
    Custom Ad Fields or Custom Profile Fields in the body of ClassiPress email messages.

    First Tutorial:


    How to add Custom
    Ad Fields to Contact ad poster notification

    MOD for ClassiPress3.2

    So how it will looks? :

    Someone is interested in your ad listing: http://acfcp.codedforest.com/ads/shamanic-timbrel/

    "wow i'm interested"


    Name: artem
    E-mail:
    blabla@blabla.com



    -----------------------------------------
    SELLER INFORMATION FOR THIS LISTING:

    Street: Somewhere In Ural Forests
    City: Yekaterinburg
    Country: Russia
    Zip/Postal Code: 620000
    Manufacturer: Unknown
    Condition: Excellent
    Colour: Each Time A New
    Delivery: Special
    -----------------------------------------
    This message was sent from Advanced Custom Fields for ClassiPress plugin DEMO
    http://acfcp.codedforest.com/

    Sent from IP Address: 00.00.000.00


    So you are interested?

    How to do:

    Decide which fields you want to show in the letter

    There are two ways:

    1. If you want show all custom Ad fields by category
    2. If you want show only necessary custom Ad fields for all categories


    First way:

    1.1 Open file /classipress/includes/theme-emails.php in line 287 (function cp_contact_ad_owner_email($postID))
    1.2 There you will see this line of code
    PHP Code:
        $message .= '-----------------------------------------' "\r\n"
    1.3 Add code below this line:
    PHP Code:
        //MOD START ==================================================================================================================

        
    $message .= __('SELLER INFORMATION FOR THIS LISTING:''appthemes') . "\r\n\r\n"

        global 
    $wpdb;

        
    $category stripslashesappthemes_get_custom_taxonomy($postIDAPP_TAX_CAT'term_id') );

        
    //Get form ID from ad category, If you have special form comment out line below
        
    $fid cp_get_form_id($category);
        
    //If you have special form uncomment line below and enter form ID
        //$fid = 1;

                // now we should have the formid so show the form layout based on the category selected
                
    $sql $wpdb->prepare("SELECT f.field_label, f.field_name "
                         
    "FROM "$wpdb->prefix "cp_ad_fields f "
                         
    "INNER JOIN "$wpdb->prefix "cp_ad_meta m "
                         
    "ON f.field_id = m.field_id "
                         
    "WHERE m.form_id = %s "
                         
    "ORDER BY m.field_pos asc",
                         
    $fid);

        
    // get results from db
        
    $results $wpdb->get_results($sql);

        if(
    $results) {
            foreach (
    $results as $result) {

                   
    //we are don't want to display title, description and tags
                
    if( $result->field_name == 'post_title' || $result->field_name == 'post_content' || $result->field_name == 'tags_input' )
                    continue;


                
    // now grab all ad fields and print out the field label and value
                
    $post_meta_val get_post_meta($postID$result->field_nametrue);

                
    //Field title
                
    $message .= stripslashesstrip_tagstranslate$result->field_label'appthemes' ) ) ) . ': '
                
    //Field value
                
    $message .= ( !empty( $post_meta_val ) ) ? stripslashesstrip_tags$post_meta_val ) ) : __('N/A''appthemes');
                
    //break line
                
    $message .= "\r\n";
            }
        }
        
    $message .= '-----------------------------------------' "\r\n";
        
    //MOD END ================================================================================================================== 
    1.4 Enjoy!!!!

    Second way:

    2.1 Open WP admin area
    2.2 Open ClassiPress Options -> Form Layouts
    2.3 Create a new custom form layout with necessary fields OR find existing (if you have)
    2.3 Open this form for edit
    2.4 Find form ID in url box of your browser /wp-admin/admin.php?page=layouts&action=editform&id=1
    2.5 Remember it
    2.6 Repeat steps 1.1-1.3
    2.7 Find in MOD this code:
    PHP Code:
        //Get form ID from ad category, If you have special form comment out line below
        
    $fid cp_get_form_id($category); 
    2.8 Comment out it:
    PHP Code:
        //Get form ID from ad category, If you have special form comment out line below
        //$fid = cp_get_form_id($category); 
    2.9 Next lines:
    PHP Code:
        //If you have special form uncomment line below and enter form ID
        //$fid = 1; 
    2.10 Uncomment last line:
    PHP Code:
        //If you have special form uncomment line below and enter form ID
        
    $fid 1
    2.11 Replace "1" with your form ID (step 2.5)
    2.12 Repeat step 1.4


    Good Luck!
    arthemes.org - AppThemes plugins, tutorials, modifications and services

  2. The Following 5 Users Say Thank You to dikiyforester For This Useful Post:

    Fanatic (December 9th, 2012), kilador (April 28th, 2013), paulogoode (December 11th, 2012), rubencio (May 11th, 2013), talent (April 28th, 2013)

  3. #2
    samcy's Avatar
    Join Date
    Mar 2012
    Location
    Germany
    Posts
    12,098
    Thanks
    121
    Thanked 1,756 Times in 1,442 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Rolf Hassel (Samcy)

  4. The Following User Says Thank You to samcy For This Useful Post:

    dikiyforester (November 20th, 2012)

  5. #3
    Amateur kilador's Avatar
    Join Date
    Jan 2012
    Location
    Spain
    Posts
    18
    Thanks
    3
    Thanked 0 Times in 0 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  6. #4
    zighsty's Avatar
    Join Date
    May 2013
    Location
    Denmark
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. New User Email Plugin in 3.02 BUG - Send Notification Email
    By zontor in forum ClassiPress General Discussion
    Replies: 15
    Last Post: December 25th, 2013, 12:23 PM
  2. Send Notification Email based on custom field date?
    By jeanne38654 in forum ClassiPress General Discussion
    Replies: 0
    Last Post: March 5th, 2012, 04:55 PM
  3. Email encoder not working in custom fields
    By jatun in forum Report ClassiPress Bugs
    Replies: 1
    Last Post: November 26th, 2011, 08:37 AM