Support » Plugin: Events Manager » global $EM_Event is NULL and em events get return void

  • in single event context the EM_Event is NULL and a em_event:get returns void with any argument. This serious bug has propagated. In the beginning only the EM_Event was null so I worked around using this code

    function ni_event_null_fix() {
      global $EM_Event;
      if($EM_Event == NULL) {
        $tmp = EM_Events::get(array('post_id'=> get_the_ID()));
        var_dump($tmp);
        if(count($tmp) == 1)
          $EM_Event = $tmp[0];
      } 
    }

    with 5.8 thing have gone worse

    I have disabled all the plugin and still doesn’t work. This happen with events of a specific category only. Any hint?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Apologies for this issue. Which is the category exactly that is giving you problems? If you try recreating it does this issue still occur?

    Thread Starter Rocco Marco Guglielmi

    (@roccomarco)

    With 5.8 it seems like it occurs with every category. Once an event is broke it newer works again (or at least I am not able to detect the breaking condition nor the fix one).

    About the workaround I have fixed it adding ‘scope’ => ‘all’ to my query arg. I can do additional test if you have any suggestion. Right now I am not able to detect root cause since I don’t know how EM works internally and I have no time to investigate deeper.

    Maybe the problem is a conditional branch in the hook which populates the global $EM_Event

    Plugin Support caimin_nwl

    (@caimin_nwl)

    Is this also happening with 5.8.1.1?

    Thread Starter Rocco Marco Guglielmi

    (@roccomarco)

    This is above all happening with 5.8.1.1

    Plugin Support caimin_nwl

    (@caimin_nwl)

    Can you explain more about what you’re trying to do with your code and where you’re using it? Thanks.

    Thread Starter Rocco Marco Guglielmi

    (@roccomarco)

    Developing theme. In single event context I use the global object to get data from the event.

    See neapolisinnovation.info and navigate events. Even the calendar widget depends on it

    Plugin Support caimin_nwl

    (@caimin_nwl)

    This seems more like this could be an issue related to the way the custom code is getting data. Where are you running your code?

    Are you using a custom single event?

    Thread Starter Rocco Marco Guglielmi

    (@roccomarco)

    I thought I have been already clear.

    is single, post type event.

    Plugin Support angelo_nwl

    (@angelo_nwl)

    would it be possible to share the code you are using for us to see and analyze? also, maybe you can try something like this?

    
    <?php
    global $post;
    $EM_Event = em_get_event($post->ID, 'post_id'); 
    
    echo $EM_Event->output('#_EVENTNAME');
    echo $EM_Event->output('#_EVENTDATES');
    echo $EM_Event->output('#_EVENTTIMES');
    ?>
    
    Thread Starter Rocco Marco Guglielmi

    (@roccomarco)

    Angelo your code is just a workaround as is mine. The problem is that the global scope variable is not correctly populated as it should be in single event context.

    Plugin Support caimin_nwl

    (@caimin_nwl)

    This seems to be more an issue with how you’re using your custom code. As far as I can see, the presence of a global variable isn’t required by Events Manager, or errors would be thrown on standard installations of the plugin.

    Adding global $post; seems to be a good workaround for what you want to do.

    Thread Starter Rocco Marco Guglielmi

    (@roccomarco)

    Well you should update your documentation (Developer Docs & Tutorials) because there is written something else

    http://wp-events-plugin.com/documentation/

    Plugin Support caimin_nwl

    (@caimin_nwl)

    Which specific page are you referring to?

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘global $EM_Event is NULL and em events get return void’ is closed to new replies.