Okay
  Public Ticket #3330443
short tags and admin email
Closed

Comments

  • trucounselmarketing started the conversation

    Can I get a list of short tags for emails (Ex: {{title}}, {{short_description}})? 

    Specifically, I want to send an email to the admin email every time a new event is posted.  

    I would like that email to include the tags for: 

    • starts on, 
    • ends on, 
    • location, 
    • name, 
    • short description, 
    • introduction, 
    • organizer, 
    • category, 
    • external link, 
    • event page url. 

    Thanks for your amazing plugin. We love it!

  •  786
    Zhivko replied

    Hi,

    Add this hook in your theme or child-theme functions.php file:

    /**
     * Registers custom special words
     * {{starts on}}
     * {{ends on}}
     * {{location}}
     * {{short description}}
     * {{introduction}}
     * {{organizer}}
     * {{category}}
     * {{external link}}
     */
    add_filter('stec_mail_add_special_words', function ($filter, $text, $event) {
        $date_format = 'Y-m-d h:i';
        $filter['replace'][] = '{{starts on}}';
        $filter['with'][]    = $event ? $event->get_start_date($date_format) : '';
        
        $filter['replace'][] = '{{ends on}}';
        $filter['with'][]    = $event ? $event->get_end_date($date_format) : '';
        
        $location            = $event ? $event->get_parsed_location() : '';
        $filter['replace'][] = '{{location}}';
        $filter['with'][]    = isset($location->full_address) ? $location->full_address : '';
        
        $filter['replace'][] = '{{short description}}';
        $filter['with'][]    = $event ? $event->get_description_short() : '';
        $filter['replace'][] = '{{introduction}}';
        $filter['with'][]    = $event ? $event->get_description() : '';
        
        $organizers          = $event ? $event->get_parsed_organizers() : '';
        $organizer           = isset($organizers[0]) ? $organizers[0] : '';
        $filter['replace'][] = '{{organizer}}';
        $filter['with'][]    = $organizer ? $organizer->name : '';
        
        $categories          = $event ? $event->get_parsed_categories() : '';
        $category            = isset($categories[0]) ? $categories[0] : '';
        $filter['replace'][] = '{{category}}';
        $filter['with'][]    = $category ? $category->title : '';
        
        $filter['replace'][] = '{{external link}}';
        $filter['with'][]    = $event ? $event->get_link('url') : '';
        return $filter;
    }, 10, 3);

    This hook will register the following tags:

      {{starts on}}
      {{ends on}}
      {{location}}
      {{short description}}
      {{introduction}}
      {{organizer}}
      {{category}}
      {{external link}}


    Stachethemes Developer