php 事件日历:阻止访问事件,组织者和场所,但管理员和E / O / V的作者除外。如果用户已注销,
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 事件日历:阻止访问事件,组织者和场所,但管理员和E / O / V的作者除外。如果用户已注销,相关的知识,希望对你有一定的参考价值。
<?php
/**
* The Events Calendar: Block access to Events, Organizers, and Venues except
* to Administrators and the E/O/V's author. If user is logged out, redirect
* to wp-login.php.
*
* Note: May result in 404s, like if an Event links to a Venue page (only in
* PRO) but the Venue author is not the same as the Event author.
*
* @link https://gist.github.com/cliffordp/f4a0e9d93c09860203929be21f3a31ff
*/
add_action( 'tribe_events_pre_get_posts', 'cliff_tec_hard_core_lockdown_to_own', 100 );
function cliff_tec_hard_core_lockdown_to_own( $query ) {
// redirect to login page if not yet logged in
if ( ! is_user_logged_in() ) {
wp_redirect( esc_url_raw( wp_login_url() ) );
exit;
}
// let admins see everything
if ( current_user_can( 'create_users' ) ) {
return;
}
// limit to the logged-in user's events
$query->set( 'author', get_current_user_id() );
}
以上是关于php 事件日历:阻止访问事件,组织者和场所,但管理员和E / O / V的作者除外。如果用户已注销,的主要内容,如果未能解决你的问题,请参考以下文章