本文整理汇总了PHP中BP_Friends_Friendship::accept方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Friends_Friendship::accept方法的具体用法?PHP BP_Friends_Friendship::accept怎么用?PHP BP_Friends_Friendship::accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BP_Friends_Friendship
的用法示例。
在下文中一共展示了BP_Friends_Friendship::accept方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: friends_accept_friendship
function friends_accept_friendship($friendship_id)
{
global $bp;
$friendship = new BP_Friends_Friendship($friendship_id, true, false);
if (!$friendship->is_confirmed && BP_Friends_Friendship::accept($friendship_id)) {
friends_update_friend_totals($friendship->initiator_user_id, $friendship->friend_user_id);
// Remove the friend request notice
bp_core_delete_notifications_by_item_id($friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request');
// Add a friend accepted notice for the initiating user
bp_core_add_notification($friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_accepted');
$initiator_link = bp_core_get_userlink($friendship->initiator_user_id);
$friend_link = bp_core_get_userlink($friendship->friend_user_id);
// Record in activity streams for the initiator
friends_record_activity(array('user_id' => $friendship->initiator_user_id, 'type' => 'friendship_created', 'action' => apply_filters('friends_activity_friendship_accepted_action', sprintf(__('%1$s and %2$s are now friends', 'buddypress'), $initiator_link, $friend_link), $friendship), 'item_id' => $friendship_id, 'secondary_item_id' => $friendship->friend_user_id));
// Record in activity streams for the friend
friends_record_activity(array('user_id' => $friendship->friend_user_id, 'type' => 'friendship_created', 'action' => apply_filters('friends_activity_friendship_accepted_action', sprintf(__('%1$s and %2$s are now friends', 'buddypress'), $friend_link, $initiator_link), $friendship), 'item_id' => $friendship_id, 'secondary_item_id' => $friendship->initiator_user_id, 'hide_sitewide' => true));
// Send the email notification
friends_notification_accepted_request($friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id);
do_action('friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id);
return true;
}
return false;
}
示例2: friends_accept_friendship
/**
* Mark a friendship request as accepted.
*
* Also initiates a "friendship_accepted" activity item.
*
* @param int $friendship_id ID of the pending friendship object.
* @return bool True on success, false on failure.
*/
function friends_accept_friendship($friendship_id)
{
// Get the friesdhip data
$friendship = new BP_Friends_Friendship($friendship_id, true, false);
// Accepting friendship
if (empty($friendship->is_confirmed) && BP_Friends_Friendship::accept($friendship_id)) {
// Bump the friendship counts
friends_update_friend_totals($friendship->initiator_user_id, $friendship->friend_user_id);
do_action('friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship);
return true;
}
return false;
}
示例3: friends_accept_friendship
/**
* Mark a friendship request as accepted.
*
* Also initiates a "friendship_accepted" activity item.
*
* @since 1.0.0
*
* @param int $friendship_id ID of the pending friendship object.
* @return bool True on success, false on failure.
*/
function friends_accept_friendship($friendship_id)
{
// Get the friendship data.
$friendship = new BP_Friends_Friendship($friendship_id, true, false);
// Accepting friendship.
if (empty($friendship->is_confirmed) && BP_Friends_Friendship::accept($friendship_id)) {
// Bump the friendship counts.
friends_update_friend_totals($friendship->initiator_user_id, $friendship->friend_user_id);
/**
* Fires after a friendship is accepted.
*
* @since 1.0.0
*
* @param int $id ID of the pending friendship object.
* @param int $initiator_user_id ID of the friendship initiator.
* @param int $friend_user_id ID of the user requested friendship with.
* @param object $friendship BuddyPress Friendship Object.
*/
do_action('friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship);
return true;
}
return false;
}
示例4: friends_accept_friendship
function friends_accept_friendship($friendship_id)
{
/* Check the nonce */
if (!check_admin_referer('friends_accept_friendship')) {
return false;
}
$friendship = new BP_Friends_Friendship($friendship_id, true, false);
if (!$friendship->is_confirmed && BP_Friends_Friendship::accept($friendship_id)) {
friends_update_friend_totals($friendship->initiator_user_id, $friendship->friend_user_id);
// Remove the friend request notice
bp_core_delete_notifications_for_user_by_item_id($friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request');
// Add a friend accepted notice for the initiating user
bp_core_add_notification($friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_accepted');
// Record in activity streams
friends_record_activity(array('item_id' => $friendship_id, 'component_name' => $bp->friends->slug, 'component_action' => 'friendship_accepted', 'is_private' => 0, 'user_id' => $friendship->initiator_user_id, 'secondary_user_id' => $friendship->friend_user_id));
// Send the email notification
require_once BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php';
friends_notification_accepted_request($friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id);
do_action('friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id);
return true;
}
return false;
}