• Resolved Michael

    (@mischnu)


    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://ww.wp.xz.cn/plugins/events-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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

    (@mischnu)

    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?

    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.