本文整理匯總了PHP中EM_Event::add_error方法的典型用法代碼示例。如果您正苦於以下問題:PHP EM_Event::add_error方法的具體用法?PHP EM_Event::add_error怎麽用?PHP EM_Event::add_error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類EM_Event
的用法示例。
在下文中一共展示了EM_Event::add_error方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: bp_em_group_event_can_manage
/**
* Overrides the default capability of the user for another owner's event if the user is a group admin and the event belongs to a group.
* User must have the relevant permissions globally in order to inherit that capability for this event as well.
* @param boolean $result
* @param EM_Event $EM_Event
*/
function bp_em_group_event_can_manage($result, $EM_Event, $owner_capability, $admin_capability, $user_to_check)
{
if (!$result && $EM_Event->event_owner != get_current_user_id() && !empty($EM_Event->group_id) && bp_is_active('groups')) {
//only override if already false, incase it's true
//if the user is an admin of this group, and actually has the relevant permissions globally, they can manage this event
$EM_Object = new EM_Object();
//create new object to prevent infinite loop should we call $EM_Event->can_manage();
if (groups_is_user_admin(get_current_user_id(), $EM_Event->group_id) && $EM_Object->can_manage($owner_capability, $admin_capability, $user_to_check)) {
//This user is an admin of the owner's group, so they can edit this event.
return true;
} else {
$EM_Event->add_error($EM_Object->get_errors());
//add any applicable errors
}
}
return $result;
}