Results 1 to 5 of 5

Thread: overriding email functions in includes/emails.php

  1. #1
    Thread Starter
    Veteran almightyeric's Avatar
    Join Date
    Aug 2011
    Location
    Nothern CA, USA
    Posts
    416
    Thanks
    56
    Thanked 19 Times in 16 Posts

    overriding email functions in includes/emails.php

    ClassiPress 3.3.2 has the following functions in includes/emails.php (list shown below).

    The following 5 are integrated into the site using filters hooks or action hooks: "cp_notify_ad_owner_email," "cp_send_buyer_receipt," "cp_send_admin_receipt," "cp_send_admin_failed_transaction," "cp_notify_admin_moderated_listing." That allows child theme or plugin developers to override those functions, by unhooking them and hooking our own. This allows us to have completely custom logic and messages in our emails.

    However, the other 6 functions are called directly throughout the site. They are not integrated via filter hooks or action hooks. Not only that, but they are not surrounded with "if !defined( function_name )" conditions, which would give priority to other functions with the same name (should any exist).

    Finally, having a custom includes/emails.php file in the child theme doesn't appear to me to affect the behavior of the site. The site still uses the file in the parent theme.

    This prevents developers from overriding those functions. In order to customize those emails and associated logic beyond what an .mo file will allow (which is limited), we can either modify this file in the parent theme OR replace all the calls to these functions throughout the theme, with calls to our own custom functions.

    Do any of you know of another way to accomplish it (i.e. to customize those emails beyond using .mo files)?

    @samcy, do you know whether AppThemes plans to integrate the other 6 functions via hooks in a future release, instead of calling them directly?

    PHP Code:
    // send new ad notification email to admin
    function cp_new_ad_email$post_id ) {}

    // send new ad notification email to ad owner
    function cp_owner_new_ad_email$post_id ) {}

    // when an ad is approved or expires, send the ad owner an email
    function cp_notify_ad_owner_email$new_status$old_status$post ) {}
    add_filter'transition_post_status''cp_notify_ad_owner_email'10);

    // ad poster sidebar contact form email
    function cp_contact_ad_owner_email$post_id ) {}

    // email that gets sent out to new users once they register
    function cp_new_user_notification$user_id$plaintext_pass '' ) {}

    // send new post report email to admin
    function app_report_post$post_id ) {}

    // send notification email to buyer when membership was activated
    function cp_owner_activated_membership_email$user$order ) {}

    /**
     * Sends email with receipt to customer after completed purchase.
     *
     * @param object $order
     */
    function cp_send_buyer_receipt$order ) {}
    add_action'appthemes_transaction_completed''cp_send_buyer_receipt' );

    /**
     * Sends email with receipt to admin after completed purchase.
     *
     * @param object $order
     */
    function cp_send_admin_receipt$order ) {}
    add_action'appthemes_transaction_completed''cp_send_admin_receipt' );

    /**
     * Sends email notification to admin if payment failed.
     *
     * @param object $order
     */
    function cp_send_admin_failed_transaction$order ) {}
    add_action'appthemes_transaction_failed''cp_send_admin_failed_transaction' );

    /**
     * Sends email notification to admin if listing require moderation.
     *
     * @param object $post
     */
    function cp_notify_admin_moderated_listing$post ) {}
    add_action'publish_to_pending''cp_notify_admin_moderated_listing'10); 

  2. #2
    Thread Starter
    Veteran almightyeric's Avatar
    Join Date
    Aug 2011
    Location
    Nothern CA, USA
    Posts
    416
    Thanks
    56
    Thanked 19 Times in 16 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  3. #3
    Thread Starter
    Veteran almightyeric's Avatar
    Join Date
    Aug 2011
    Location
    Nothern CA, USA
    Posts
    416
    Thanks
    56
    Thanked 19 Times in 16 Posts

    tutorial

    You must be an AppThemes customer and logged in to view this response. Join today!

  4. The Following 2 Users Say Thank You to almightyeric For This Useful Post:

    bleem (February 8th, 2014), usa4sale (August 28th, 2014)

  5. #4
    Thread Starter
    Veteran almightyeric's Avatar
    Join Date
    Aug 2011
    Location
    Nothern CA, USA
    Posts
    416
    Thanks
    56
    Thanked 19 Times in 16 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  6. #5
    Veteran bleem's Avatar
    Join Date
    Feb 2012
    Posts
    1,572
    Thanks
    103
    Thanked 205 Times in 180 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  7. The Following User Says Thank You to bleem For This Useful Post:

    almightyeric (February 8th, 2014)

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Dimitris "Contact Listing Owner" sends email even if no entry are made
    By bvpraveen in forum Report Vantage Bugs (Legacy)
    Replies: 5
    Last Post: January 16th, 2014, 05:01 AM
  2. Unable to access "contact" or "poster" tabs in Android browser (classipress)
    By scharpliving in forum ClassiPress General Discussion
    Replies: 2
    Last Post: September 9th, 2013, 04:37 AM
  3. Replies: 2
    Last Post: September 9th, 2013, 04:37 AM
  4. Samcy How do I Change "poster" to "contact seller"
    By consignor in forum Report ClassiPress Bugs
    Replies: 6
    Last Post: December 3rd, 2012, 03:45 PM
  5. [BUG] CP's "Contact" form overrides the "From" in other email plugins
    By ejikoala in forum Report ClassiPress Bugs
    Replies: 1
    Last Post: October 29th, 2010, 08:11 PM