How to modify list of events in backend (admin) of The Events Calendar plugin?

In my Wordpress site I use plugin The Events Calendar (pro). There is a page with list of Events in backend. Link to thi

In my Wordpress site I use plugin The Events Calendar (pro). There is a page with list of Events in backend. Link to this page looks like this: .php?post_type=tribe_events

So now I need to hook/filter into this list of events to modify it. My task is to initially show events of only one particular organizer.

Tried looking through exisiting hooks and filters of this plugin. But nothing seems to suit me. Also tried looking into plugin files, but couldn't find the one that is responsible for list of events in backend.

In my Wordpress site I use plugin The Events Calendar (pro). There is a page with list of Events in backend. Link to this page looks like this: https://example/wp-admin/edit.php?post_type=tribe_events

So now I need to hook/filter into this list of events to modify it. My task is to initially show events of only one particular organizer.

Tried looking through exisiting hooks and filters of this plugin. But nothing seems to suit me. Also tried looking into plugin files, but couldn't find the one that is responsible for list of events in backend.

Share Improve this question asked Aug 28, 2019 at 14:23 Kirill OzeritskiKirill Ozeritski 214 bronze badges 2
  • 2 Check with The Events Calendar's official support streams. – Pat J Commented Aug 28, 2019 at 14:36
  • @PatJ I did. Nothing there. – Kirill Ozeritski Commented Aug 29, 2019 at 15:46
Add a comment  | 

1 Answer 1

Reset to default 1

Okay, I found the solution myself. I used the WordPress hook parse_query. This is the most precise thing I found. And in this hook I check if it is backend and my user has his meta data called "organizer_id" which I added earlier. But it is only to get the needed organizer_id for filtering the list.

Here's the code:

add_filter( 'parse_query', 'ozz_filter_events_by_organizer' );
function ozz_filter_events_by_organizer( $query ) {
    $current_user = wp_get_current_user();
    $organizer_id = get_user_meta( $current_user->ID, 'organizer_id' );

    if ( is_admin() and $query->query['post_type'] == 'tribe_events' and !empty( $organizer_id ) ) {
        $qv = &$query->query_vars;
        $qv['meta_query'][] = array(
            'field' => '_EventOrganizerID',
            'value' => $organizer_id
        );

        //echo '<pre>' . print_r( $qv, true ) . '</pre>';
    }
}

So this filter-hook fires each time there is a query on the site. Not very handy but best I could find. So it allowed me to filter the query when it considered particularly the event list in the backend.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745169827a4614857.html

相关推荐

  • How to modify list of events in backend (admin) of The Events Calendar plugin?

    In my Wordpress site I use plugin The Events Calendar (pro). There is a page with list of Events in backend. Link to thi

    13小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信