Check Out Our Newest Developed Magento 2 Extensions More Info

Solution Guide : Shortcodes for Message Template of Event Espresso

blog-img

In Default Message Template of Event Espresso some Shortcode are available for Dynamic values.

But sometimes developer/admin will want some other values which is not in a Default Shortcodes.

So, Here are some steps for developer/admin to create Custom Shortcodes in Default Message Template of Event Espresso :

Developer/Admin can create a shortcode for Dynamic Values and also for Static Values.

Step 1 : Create a Events with custom field (for Dynamic Values).

Step 2 : After publishes the Events we have ready to create a shortcodes.

First we have to know about Majorly used Event Espresso Shortcodes Libraries

  • Event_List
  • Attendee List
  • Ticket List
  • DateTime List

Decide in which library we want to create a Shortcode.

Related : Elsner’s Recently Launched WordPress Plugin: Posts Slider Shortcode

Step 3 : “FHEE__EE_Shortcodes__shortcodes
With the above filter we can create a Shortcode of Message Template.
(Above Filter have 2 Arguments)
(Only create a Shortcode with this, but shortcode doesn’t have any value)

: Step 4 : “FHEE__EE_Shortcodes__parser_after
(Above Filter have 5 Arguments)
With the above filter we can add a value in a Shortcode of Message Template.
>> Let’s Start to create a Custom Shortcode in [Event List] <<

function register_new_shortcodes( $shortcodes, EE_Shortcodes $lib ) {

if ( $lib instanceof EE_Event_Shortcodes ) {
$shortcodes['[Shortcode_Name]'] = _('Description for Custom Shortcode...!');
$shortcodes['[Event_Landmark]'] = _('Custom Shortcode for Event Landmark!');
}

return $shortcodes;
}
add_filter( 'FHEE__EE_Shortcodes__shortcodes', 'register_new_shortcodes', 10, 2 );

>> Now set a Value for a Custom Shortcodes <<

function register_new_shortcodes_parser( $parsed, $shortcode, $data, $extra_data, EE_Shortcodes $lib ) {
if ( $lib instanceof EE_Event_Shortcodes && $data instanceof EE_Event ) {
// Get the Current Event ID
$evt_id = $data->get('EVT_ID');

// Dynamic value
// Custom Field Slug = event_landmark
if ( $shortcode == '[Event_Landmark]' ) {
$temp_evt = get_field('event_landmark',$evt_id);
return $temp_evt;
}
}

// Static value
if ( $shortcode == '[Shortcode_Name]' ) {
$temp_evt = 'Static Value Here'
return $temp_evt;
}
}
return $parsed;
}
add_filter( 'FHEE__EE_Shortcodes__parser_after', 'register_new_shortcodes_parser', 10, 5 );

Related : How to Submit Your Plugin to WordPress Plugin Directory?

For other libraries

Wordpress development

WordPress Development Company

Note:- Above code is write in the function.php file of current theme.

On wordpress.org one Plugin is available for create a Email Shortcode for Message Template of Event Espresso.

You can find that plugin “Email Shortcode” on this link :
http://wordpress.org/plugins/email-shortcode/

Related : 10 Tips to Secure Your WordPress Website

 

August 2017

Elsner Admin

Let Us Help You

Build Your Brand!