Skip Navigation

[Resolved] How to change Classifieds reference site email notifications

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to know how to make some changes to the email notifications sent by CRED in the Classifieds reference site. I would like to change the "from" address to match the message sender, and I would like to include the corresponding Ad title in the message.

Solution:
Include a hidden generic field that captures the listing title in the form. Then use that field value in your email notification. You can edit the form here:
yoursite.com/wp-admin/post.php?post=6337&action=edit
Since the listing ID shows up in the URL where the form is displayed, you can access that ID using the wpv-search-term shortcode like this:

[wpv-search-term param='listing-id']

Then you can figure out the Listing Title from that ID like this:

[wpv-post-title id="[wpv-search-term param='listing-id']"]

Insert that as the value of your generic field:

[cred_generic_field field='listing_title' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[wpv-post-title id='[wpv-search-term param='listing-id']']"
}
[/cred_generic_field]

Then you can use that title in your CRED notification with this shortcode:

[wpv-post-field name="listing_title"]

and the from address is not from the sender.
There's not an easy way to select the current User's ID as the "from" address in the notification editor. You can use the CRED API method cred_mail_header to modify the "From:" email header programmatically.

Here's an example:

//Customise CRED notifications
add_filter('cred_mail_header', 'customise_cred_message_from', 10, 5);
function customise_cred_message_from( $headers, $formid, $postid, $notification_name, $notification_number ) {
    if ($formid==12345 && $notification_number==67890) {
        $current_user = wp_get_current_user();
        $myheaders = array( 'From: ' . $current_user->user_email );
        return array_merge($headers, $myheaders);
    }
    return $headers;
}

Modify 12345 to match your CRED form ID, and change 67890 to match the notification index (zero if no other notifications exist for this form)

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-search-term
https://toolset.com/documentation/programmer-reference/cred-api/#cred_mail_header

This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#615670

Sorry for the undescriptive title.

I have a classifieds site running, now when a potential buyer sends a message the creator of the ad can view the message on their my account page and they receive an email, however, the email does not tell the ad creator what ad he/she is being contacted about and the from address is not from the sender.

Is there a way to configure the email sent to the ad creator that will tell them what they are being contacted about and also change the from email address to that of the sender instead of "wordpress@xyz.com"

#615829

the email does not tell the ad creator what ad he/she is being contacted about
No, you would have to make some changes to include the listing title. One option is to include a hidden generic field that captures the listing title in the form. Then use that field value in your email notification. You can edit the form here:
yoursite.com/wp-admin/post.php?post=6337&action=edit
Since the listing ID shows up in the URL where the form is displayed, you can access that ID using the wpv-search-term shortcode like this:

[wpv-search-term param='listing-id']

Then you can figure out the Listing Title from that ID like this:

[wpv-post-title id="[wpv-search-term param='listing-id']"]

Insert that as the value of your generic field:

[cred_generic_field field='listing_title' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[wpv-post-title id='[wpv-search-term param='listing-id']']"
}
[/cred_generic_field]

Then you can use that title in your CRED notification with this shortcode:

[wpv-post-field name="listing_title"]

and the from address is not from the sender.
There's not an easy way to select the current User's ID as the "from" address in the notification editor. You can use the CRED API method cred_mail_header to modify the "From:" email header programmatically:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_mail_header

Here's an example:

//Customise CRED notifications
add_filter('cred_mail_header', 'customise_cred_message_from', 10, 5);
function customise_cred_message_from( $headers, $formid, $postid, $notification_name, $notification_number ) {
    if ($formid==12345 && $notification_number==67890) {
        $current_user = wp_get_current_user();
        $myheaders = array( 'From: ' . $current_user->user_email );
        return array_merge($headers, $myheaders);
    }
    return $headers;
}

Modify 12345 to match your CRED form ID, and change 67890 to match the notification index (zero if no other notifications exist for this form)

#615948

Awesome!

Thanks very much 🙂

#615995

Sorry, just one more question.

Where do I edit the content of the email that gets sent to the advertiser?

#615997

Oh crap!

I'm sorry I missed it, found it.