• Resolved honoluluman

    (@honoluluman)


    Hello and thank you for this great plugin,

    In your wp-content/plugins/mp-timetable/templates/widgets/widget-view.php at line 41 you have if (!empty($events)) .

    I need to use this condition in my functions.php. Could you help me how can i define the $events arg when an event is taking place?

    Thank you for your time

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support eugenewhite

    (@eugenewhite)

    Hello there!

    Sorry for such a late response.
    In case you still need our assistance, please, provide some details so we can see what exactly you’re trying to complete.
    Thank you!

    Thread Starter honoluluman

    (@honoluluman)

    Hello and thank you very much for your reply ??

    I need to create an if condition in my functions.php that can be true during the time that the event of a user (that is the author of the event as a post type) is taking place & the current logged in user is the same user.

    Basically something like this:

     $user_id = get_current_user_id();
      $eventuser_id = // get the id of the author the is assigned to an event that is an Ongoing event.  
    if ( $user_id == $eventuser_id ) {  ..... } 

    Could you please help me?

    Thread Starter honoluluman

    (@honoluluman)

    Hello,

    So i’ve found how to get the id of the author of the event.
    if ( get_current_user_id() == get_post($event_id)->post_author ) { ..... }

    My only question is how can i retrieve the ongoing event’s ID $event_id= inside my functions.php?

    Could you please help me?

    Thread Starter honoluluman

    (@honoluluman)

    Any reply please?

    Plugin Support eugenewhite

    (@eugenewhite)

    Hello there! 

    We’re terribly sorry for the late reply. 

    Probably you already managed to complete what you need, but anyway, here’s the code that may be used to get upcoming events:

    $eventsClass = mp_timetable\classes\models\Events:get_instanse();
    
    $args = array(
     ???'mp_categories' => array(), // categories slugs
     ???'view_settings' => 'current', // can be 'today', 'current', 'all'
     ???'next_days' => 1, // numer of days to include upcoming events
     ???'limit' > 0 // number of events to load
    );
    
    $events = $eventsClass->get_widget_events( $args );

    Let me know if it’s helpful, if it’s still relevant, of course.

    Thread Starter honoluluman

    (@honoluluman)

    @eugenewhite thank you very much for the help and the code.
    I have tried to place the code as it is, in my functions.php but unfortunately it breaks the site.

    $eventsClass = mp_timetable\classes\models\Events:get_instanse();
    
    $args = array(
        'mp_categories' => array('rock','pop','classical'), // categories slugs
        'view_settings' => 'current',
        'next_days' => 7, //all the days of the week
        'limit' = 1 // load only 1
    );
    
    $events = $eventsClass->get_widget_events( $args );

    I do understand how the code works, but can’t understand why it breaks.

    Is there maybe some mistake in the code?
    Thank you very much for your help.

    Plugin Support eugenewhite

    (@eugenewhite)

    Hello there.

    Sorry for such a late response. 

    I would like to inform you that the provided code is not meant to work as a plugin function from the functions.php file. 

    It rather can be used as a part of your own code that will responsible for getting and displaying upcoming events.?

    Thread Starter honoluluman

    (@honoluluman)

    @eugenewhite thank you very much for your reply. However there seems to be 2 mistakes in your code.
    1. ::get_instance();
    2. 'limit' => 0 // number of events to load
    The code works correct inside functions.php file.
    So the correct code would be

    $eventsClass = mp_timetable\classes\models\Events::get_instance();
    $args = array( 'mp_categories' => array(), // categories slugs
    'view_settings' => 'current', // can be 'today', 'current',
    'all' 'next_days' => 1, // numer of days to include upcoming events
    'limit' => 0 // number of events to load );

    $events = $eventsClass->get_widget_events( $args );

    • This reply was modified 2 years, 1 month ago by honoluluman.
    Plugin Support eugenewhite

    (@eugenewhite)

    Hello there!

    Well, of course, the ‘limit’ value can be changed according to your needs. As for “get_instance()”, I’m not 100% sure about that, to be honest. 

    So may I ask you if you tried to use the code already or not yet?  

    Thread Starter honoluluman

    (@honoluluman)

    I have used the code and it is working perfect. Its just there where those 2 mistakes on the original code. Thank you very much!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Condition when event is taking place’ is closed to new replies.