Okay
  Public Ticket #2481106
Default settings admin
Closed

Comments

  •  3
    Brewstar started the conversation

    Hi,

    Adding attendees under the Attendance tab in the Admin, my client would like to have ‘Existing user’ and ‘Attending’ as the default values. Is there a way to change these defaults?

    So far I’ve managed to change them in the attendance.php (stachethemes_event_calendarviewadminevents absattendance) together with the icons belonging to the different states in the main.js (.../stachethemes_event_calendar/assets/js/admin).

    But there are still some issues I haven’t been able to resolve myself…

    Could you give me a little push in the right direction?

    High regards!

  •  776
    Zhivko replied

    Hi,

    Open your theme or child-theme functions.php file and add following code:

    /**
     * STEC MOD
     * Attendance default values - Existing user; Accepted
     */
    add_action('admin_enqueue_scripts', function($hook) {
        if ('st-event-calendar_page_stec_menu__events' === $hook) {
            add_action('admin_footer', function() {
                ?>
                <script type="text/javascript">
                   (function($){
                       $('.stachethemes-admin-select[name="invite_by"]').val('user');
                       $('.stachethemes-admin-select[name="attendee_status"]').val(1);
                   })(window.jQuery);
                </script>
                <?php
            });
        }
    });



    Stachethemes Developer

  •  3
    Brewstar replied

    Hi,

    Thank you this works (perfectly)! 

    I have another request, can I sort the list of existing users on last name (or a different slug/ parameter, now it's on display name) on the attendance tab?

    High regards,

    Jochem

  •  776
    Zhivko replied

    This code should order the attendees in the admin by last name.


    Stachethemes Developer

  •  3
    Brewstar replied

    Also nice to have ;-)

    But I meant the list 'Existing users' under 'Add attendees' on the Attendance tab.

    See attachment.

    Jochem

  •  3
    Brewstar replied

    ...correct attachment

  •  776
    Zhivko replied

    Open file stachethemes_event_calendar\view\admin\events\index.php

    and edit lines 77 and 90 from:

    $users                       = get_users(array('fields' => array('display_name', 'user_email', 'ID')));

    to:

    $users                       = get_users(array('fields' => array('display_name', 'user_email', 'ID'), 'orderby' => 'meta_value', 'meta_key' => 'last_name'));


    This change will be included in the next update.


    Stachethemes Developer

  •  3
    Brewstar replied

    Great! (and perfect support)


  •  3
    Brewstar replied

    Hi,

    Can this list 'Existing users' (under 'Add attendees' on the Attendance tab) show only a specific user role?

    Now it shows all users - including the deceased members of my client.

    Regards,

    Jochem

  •  776
    Zhivko replied

    Edit further the code by adding role__in filter:

    $users = get_users(array('fields' => array('display_name', 'user_email', 'ID'), 'orderby' => 'meta_value', 'meta_key' => 'last_name', 'role__in' => array('administrator')));

    The new filter is this one:

    'role__in' => array('administrator')

    Just change administrator with the role(s) you need.


    Example:

    'role__in' => array('role1','role2','etc...')



    Stachethemes Developer

  •  3
    Brewstar replied

    Super!!

  •  3
    Brewstar replied

    Hi,

    Since the last update - 3.1.7 - these codes don't work anymore. You have an idea why? 

    Regards,

    Jochem



  •  776
    Zhivko replied

    Hi,

    Some of the changes were included in the update.

    Which code exactly does not work?


    Stachethemes Developer

  •  3
    Brewstar replied

    Hi,

    This one:

    /**
     * STEC MOD
     * Attendance default values - Existing user; Accepted
     */
    add_action('admin_enqueue_scripts', function($hook) {
        if ('st-event-calendar_page_stec_menu__events' === $hook) {
            add_action('admin_footer', function() {
                ?>
                <script type="text/javascript">
                   (function($){
                       $('.stachethemes-admin-select[name="invite_by"]').val('user');
                       $('.stachethemes-admin-select[name="attendee_status"]').val(1);
                   })(window.jQuery);
                </script>
                <?php
            });
        }
    });
  •  776
    Zhivko replied

    Yes, we've recently edited the calendar name in the dashboard so the hook changed.

    Here's the new code:

    /**
     * STEC MOD
     * Attendance default values - Existing user; Accepted
     */
    add_action('admin_enqueue_scripts', function($hook) {
        
        if ('stec_page_stec_menu__events' === $hook) {
            add_action('admin_footer', function() {
                ?>
                <script type="text/javascript">
                   (function($){
                       console.log('da e');
                       $('.stachethemes-admin-select[name="invite_by"]').val('user');
                       $('.stachethemes-admin-select[name="attendee_status"]').val(1);
                   })(window.jQuery);
                </script>
                <?php
            });
        }
    });

    Stachethemes Developer

  •  3
    Brewstar replied

    Thx it works again!