admin管理员组文章数量:1414621
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
1 Answer
Reset to default 1Okay, 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.
本文标签: How to modify list of events in backend (admin) of The Events Calendar plugin
版权声明:本文标题:How to modify list of events in backend (admin) of The Events Calendar plugin? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745169827a2645906.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论