Okay
  Public Ticket #2268736
Default calendar
Closed

Comments

  •  2
    Matthieu started the conversation

    Hi,

    On my project I would have only one calendar. There will be no other.

    Is it possible to set a default calendar?

    I would like that when a user publishes an event in front office (with the event submission form), he isn't forced to choose the calendar in the selected list (as on the demo (fields in attachment). Especially since I only have one calendar...

    Thanks!

    Matthieu

  •  795
    Zhivko replied

    Hi,

    Add this filter in your theme functions.php file:

    add_filter('stec_builder_front_elements', function($elements) {
    
        $calendar_id = 1; // set to the calendar id number
        
        $elements['calendar'] = array(
            sprintf('<input type="hidden" name="calendar_id" value="%d" />', $calendar_id)
        );
        
        return $elements;
    });

    Change $calendar_id value to your calendar id.


    Stachethemes Developer

  •   Matthieu replied privately
  •  795
    Zhivko replied

    Try out this filter:

    /**
     * Only super user and event authors can edit their events
     */
    add_filter('stec_user_can_edit_event', function($default, $event) {     if (is_super_admin()) {
            return true;
        }     $current_user_id = get_current_user_id();     if (is_user_logged_in() && $event->get_author() === $current_user_id) {
            return true;
        } else {
            return false;
        }
        
    }, 10, 2);

    Stachethemes Developer

  •  2
    Matthieu replied

    Super!