Title: Access $EM_Event::output in function
Last modified: September 1, 2016

---

# Access $EM_Event::output in function

 *  Resolved [Michael](https://wordpress.org/support/users/mischnu/)
 * (@mischnu)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/access-em_eventoutput-in-function/)
 * Hi there,
 * I want to include a Ninja Form on every event detail page by simply inserting
   the form’s short code in the event description. On submission, the form should
   contain the event name and date. Therefor I created a function like this:
 *     ```
       function collect_event_name_and_date( $field_id, $data ) {
         global $post;
         $EM_Event = em_get_event($post->ID, 'post_id');
         $event_name_and_date = $EM_Event->output('#_EVENTNAME') . " / " . $EM_Event->output('#_EVENTDATES');
         . . .
       ```
   
 * This will work fine so far.
 * But now I need to insert content from another plugin via short code right before
   the form’s short code. This will break my function, as obviously now the `$post`
   doesn’t reference to the event anymore but to the inserted plugin’s content. 
   I hope I could explain this quite understandable. 😳
 * So, is there a way to geht the event’s name and date into my function?
 * Thanks in advance for any help!
 * [https://wordpress.org/plugins/events-manager/](https://wordpress.org/plugins/events-manager/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [caimin_nwl](https://wordpress.org/support/users/caimin_nwl/)
 * (@caimin_nwl)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/access-em_eventoutput-in-function/#post-7623140)
 * Hi,
 * May be you could add an argument to the function to pass in the post ID so that
   you don’t need to use_ $post->ID_ in your function?
 *  Thread Starter [Michael](https://wordpress.org/support/users/mischnu/)
 * (@mischnu)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/access-em_eventoutput-in-function/#post-7623179)
 * Thanks Caimin,
    sorry for asking back, but I’m quite new to all of that stuff.
   So you mean from my function above I should hook into the Events Manager and 
   grab the ID of the currently displayed event? Or do I need to write a separate
   function?
 *  [caimin_nwl](https://wordpress.org/support/users/caimin_nwl/)
 * (@caimin_nwl)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/access-em_eventoutput-in-function/#post-7623247)
 * I meant that you could add an extra element to functions argument, like this…
 * `function collect_event_name_and_date( $field_id, $data, $eventid )`
 * …and then pass a value for $eventid when you use the function.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Access $EM_Event::output in function’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)

 * 3 replies
 * 2 participants
 * Last reply from: [caimin_nwl](https://wordpress.org/support/users/caimin_nwl/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/access-em_eventoutput-in-function/#post-7623247)
 * Status: resolved