Okay
  Public Ticket #2234823
Category for Cronjob import
Closed

Comments

  •  1
    Matt started the conversation

    Hello, I was wondering if it was possible to assign all events from a specific cronjob to a category. 

    I'd like to import a few different sources and each one would be assigned to a different category within the calendar

  •  1
    Matt replied

    I just realized that I could do this using different calendars instead of categories (creating a calendar for each import instead of a category), but would still be interested if you have a "category" based solution

  •  793
    Zhivko replied

    Hi,

    You can add filter for this in your theme functions.php file:

    // Imported events will added to categories 1,2 and 3.
    add_filter('stec_before_import_event', function($data){
    
        $event = &$data['event_post'];
        
        if (false === $event instanceof \Stachethemes\Stec\Event_Post) {
            return $data;
        }
             // EDIT THIS VALUE
        $categories = array(1,2,3); // the event categories 1,2,3 are categories ids
        
        $event->set_categories($categories);
        
        return $data;
    });

    The downside of this is you will have to manually asign the category ids after each import.


    Stachethemes Developer