Email Notification Shortcodes

This topic contains 5 replies, has 2 voices, and was last updated by  Giri 8 years ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #290737

    Jaz Brooks
    Buyer
    Post count: 3

    Hi there,

    My client is asking for more options of shortcode in the email notifications section – specifically adding City/Country as a lot of the companies in the directory have multiple locations. Is there a way to do this?

    Thanks.

    #290866

    Giri
    Expired Member
    Post count: 3155

    Hi Jaz,

    We have filters in our email function. So you can alter the message via filters.

    For example

    If your client is using

    [#jaz_country#]

    as shortcode, then you need to add the following code in your client’s functions.php file.

    
    
    function geodir_alter_email_message($message) {
        $search_array  = array(
            '[#jaz_country#]',
        );
        $replace_array = array(
            "United States"
        );
        $message = str_replace( $search_array, $replace_array, $message );
        return $message;
    }
    add_filter('geodir_sendEmail_message', 'geodir_alter_email_message', 10, 1);

    That would print “United States” always.

    I believe you are talking about the listing city/country.

    In that case use the following code instead of the above code.

    
    
    
    function geodir_alter_email_message($message, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id ) {
    
        $post_address = "";
        $post_city = "";
        $post_region = "";
        $post_zip = "";
        $post_country = "";
        
        if ($post_id) {
            $post = geodir_get_post_info($post_id);
            if($post->post_address) {
                $post_address = $post->post_address;
            }
            if($post->post_city) {
                $post_city = $post->post_city;
            }
            if($post->post_region) {
                $post_region = $post->post_region;
            }
            if($post->post_zip) {
                $post_zip = $post->post_zip;
            }
            if($post->post_country) {
                $post_country = $post->post_country;
            }
        }
        $search_array  = array(
            '[#jaz_address#]',
            '[#jaz_city#]',
            '[#jaz_region#]',
            '[#jaz_zip#]',
            '[#jaz_country#]',
        );
        $replace_array = array(
            $post_address,
            $post_city,
            $post_region,
            $post_zip,
            $post_country
        );
        $message = str_replace( $search_array, $replace_array, $message );
        return $message;
    }
    add_filter('geodir_sendEmail_message', 'geodir_alter_email_message', 10, 11);

    Let me know how that goes.

    Thanks

    #300162

    Jaz Brooks
    Buyer
    Post count: 3

    Thanks Giri. Sorry for the lack of reply, I’ve been away. Will be testing this out this week and let you know how it goes.

    #300164

    Giri
    Expired Member
    Post count: 3155

    No problem Jaz.

    Let me know if you need my help.

    Thanks

    #303265

    Jaz Brooks
    Buyer
    Post count: 3

    Hey Giri,

    This worked perfectly in all the email notifications except the Post Submitted Successfully Admin BCC one (just shows the shortcodes). Any idea why?

    Thanks very much!

    #303267

    Giri
    Expired Member
    Post count: 3155

    The filters were not available in admin emails. But we have added support for that last week. In next version of GD, admin mails would work too.

    Thanks

Viewing 6 posts - 1 through 6 (of 6 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount