本文整理汇总了PHP中friends_withdraw_friendship函数的典型用法代码示例。如果您正苦于以下问题:PHP friends_withdraw_friendship函数的具体用法?PHP friends_withdraw_friendship怎么用?PHP friends_withdraw_friendship使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了friends_withdraw_friendship函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: friends_screen_requests
/**
* Catch and process the Requests page.
*/
function friends_screen_requests()
{
if (bp_is_action_variable('accept', 0) && is_numeric(bp_action_variable(1))) {
// Check the nonce
check_admin_referer('friends_accept_friendship');
if (friends_accept_friendship(bp_action_variable(1))) {
bp_core_add_message(__('Friendship accepted', 'buddypress'));
} else {
bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error');
}
bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
} elseif (bp_is_action_variable('reject', 0) && is_numeric(bp_action_variable(1))) {
// Check the nonce
check_admin_referer('friends_reject_friendship');
if (friends_reject_friendship(bp_action_variable(1))) {
bp_core_add_message(__('Friendship rejected', 'buddypress'));
} else {
bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error');
}
bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
} elseif (bp_is_action_variable('cancel', 0) && is_numeric(bp_action_variable(1))) {
// Check the nonce
check_admin_referer('friends_withdraw_friendship');
if (friends_withdraw_friendship(bp_loggedin_user_id(), bp_action_variable(1))) {
bp_core_add_message(__('Friendship request withdrawn', 'buddypress'));
} else {
bp_core_add_message(__('Friendship request could not be withdrawn', 'buddypress'), 'error');
}
bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
}
do_action('friends_screen_requests');
bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home'));
}
示例2: friends_screen_requests
/**
* Catch and process the Requests page.
*/
function friends_screen_requests()
{
if (bp_is_action_variable('accept', 0) && is_numeric(bp_action_variable(1))) {
// Check the nonce
check_admin_referer('friends_accept_friendship');
if (friends_accept_friendship(bp_action_variable(1))) {
bp_core_add_message(__('Friendship accepted', 'buddypress'));
} else {
bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error');
}
bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
} elseif (bp_is_action_variable('reject', 0) && is_numeric(bp_action_variable(1))) {
// Check the nonce
check_admin_referer('friends_reject_friendship');
if (friends_reject_friendship(bp_action_variable(1))) {
bp_core_add_message(__('Friendship rejected', 'buddypress'));
} else {
bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error');
}
bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
} elseif (bp_is_action_variable('cancel', 0) && is_numeric(bp_action_variable(1))) {
// Check the nonce
check_admin_referer('friends_withdraw_friendship');
if (friends_withdraw_friendship(bp_loggedin_user_id(), bp_action_variable(1))) {
bp_core_add_message(__('Friendship request withdrawn', 'buddypress'));
} else {
bp_core_add_message(__('Friendship request could not be withdrawn', 'buddypress'), 'error');
}
bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
}
/**
* Fires before the loading of template for the friends requests page.
*
* @since BuddyPress (1.0.0)
*/
do_action('friends_screen_requests');
/**
* Filters the template used to display the My Friends page.
*
* @since BuddyPress (1.0.0)
*
* @param string $template Path to the friends request template to load.
*/
bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home'));
}
示例3: test_requests_on_withdraw
/**
* @group friends_get_friendship_request_user_ids
* @group friends_add_friend
* @group friends_withdraw_friendship
*/
public function test_requests_on_withdraw()
{
$u1 = $this->factory->user->create();
$u2 = $this->factory->user->create();
// request friendship
friends_add_friend($u2, $u1);
// get request count for user 1 and assert
$requests = friends_get_friendship_request_user_ids($u1);
$this->assertEquals(array($u2), $requests);
// user 2 withdraws friendship
$old_user = get_current_user_id();
$this->set_current_user($u2);
friends_withdraw_friendship($u2, $u1);
// refetch request count for user 1 and assert
$requests = friends_get_friendship_request_user_ids($u1);
$this->assertEquals(array(), $requests);
$this->set_current_user($old_user);
}
示例4: bp_legacy_theme_ajax_addremove_friend
/**
* Friend/un-friend a user via a POST request.
*
* @return string HTML
* @since BuddyPress (1.2)
*/
function bp_legacy_theme_ajax_addremove_friend()
{
// Bail if not a POST action
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
// Cast fid as an integer
$friend_id = (int) $_POST['fid'];
// Trying to cancel friendship
if ('is_friend' == BP_Friends_Friendship::check_is_friend(bp_loggedin_user_id(), $friend_id)) {
check_ajax_referer('friends_remove_friend');
if (!friends_remove_friend(bp_loggedin_user_id(), $friend_id)) {
echo __('Friendship could not be canceled.', 'buddypress');
} else {
echo '<a id="friend-' . esc_attr($friend_id) . '" class="add" rel="add" title="' . __('Add Friend', 'buddypress') . '" href="' . wp_nonce_url(bp_loggedin_user_domain() . bp_get_friends_slug() . '/add-friend/' . $friend_id, 'friends_add_friend') . '">' . __('Add Friend', 'buddypress') . '</a>';
}
// Trying to request friendship
} elseif ('not_friends' == BP_Friends_Friendship::check_is_friend(bp_loggedin_user_id(), $friend_id)) {
check_ajax_referer('friends_add_friend');
if (!friends_add_friend(bp_loggedin_user_id(), $friend_id)) {
echo __(' Friendship could not be requested.', 'buddypress');
} else {
echo '<a id="friend-' . esc_attr($friend_id) . '" class="remove" rel="remove" title="' . __('Cancel Friendship Request', 'buddypress') . '" href="' . wp_nonce_url(bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/cancel/' . $friend_id . '/', 'friends_withdraw_friendship') . '" class="requested">' . __('Cancel Friendship Request', 'buddypress') . '</a>';
}
// Trying to cancel pending request
} elseif ('pending' == BP_Friends_Friendship::check_is_friend(bp_loggedin_user_id(), $friend_id)) {
check_ajax_referer('friends_withdraw_friendship');
if (friends_withdraw_friendship(bp_loggedin_user_id(), $friend_id)) {
echo '<a id="friend-' . esc_attr($friend_id) . '" class="add" rel="add" title="' . __('Add Friend', 'buddypress') . '" href="' . wp_nonce_url(bp_loggedin_user_domain() . bp_get_friends_slug() . '/add-friend/' . $friend_id, 'friends_add_friend') . '">' . __('Add Friend', 'buddypress') . '</a>';
} else {
echo __("Friendship request could not be cancelled.", 'buddypress');
}
// Request already pending
} else {
echo __('Request Pending', 'buddypress');
}
exit;
}
示例5: bp_dtheme_ajax_addremove_friend
/**
* Friend/un-friend a user via a POST request.
*
* @return string HTML
* @since BuddyPress (1.2)
*/
function bp_dtheme_ajax_addremove_friend()
{
// Bail if not a POST action
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
if ('is_friend' == BP_Friends_Friendship::check_is_friend(bp_loggedin_user_id(), $_POST['fid'])) {
check_ajax_referer('friends_remove_friend');
if (!friends_remove_friend(bp_loggedin_user_id(), $_POST['fid'])) {
echo __('Friendship could not be canceled.', 'logicalboneshug');
} else {
echo '<a id="friend-' . $_POST['fid'] . '" class="add" rel="add" title="' . __('Add Friend', 'logicalboneshug') . '" href="' . wp_nonce_url(bp_loggedin_user_domain() . bp_get_friends_slug() . '/add-friend/' . $_POST['fid'], 'friends_add_friend') . '">' . __('Add Friend', 'logicalboneshug') . '</a>';
}
} elseif ('not_friends' == BP_Friends_Friendship::check_is_friend(bp_loggedin_user_id(), $_POST['fid'])) {
check_ajax_referer('friends_add_friend');
if (!friends_add_friend(bp_loggedin_user_id(), $_POST['fid'])) {
echo __(' Friendship could not be requested.', 'logicalboneshug');
} else {
echo '<a id="friend-' . $_POST['fid'] . '" class="remove" rel="remove" title="' . __('Cancel Friendship Request', 'logicalboneshug') . '" href="' . wp_nonce_url(bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/cancel/' . (int) $_POST['fid'] . '/', 'friends_withdraw_friendship') . '" class="requested">' . __('Cancel Friendship Request', 'logicalboneshug') . '</a>';
}
} elseif ('pending' == BP_Friends_Friendship::check_is_friend(bp_loggedin_user_id(), (int) $_POST['fid'])) {
check_ajax_referer('friends_withdraw_friendship');
if (friends_withdraw_friendship(bp_loggedin_user_id(), (int) $_POST['fid'])) {
echo '<a id="friend-' . $_POST['fid'] . '" class="add" rel="add" title="' . __('Add Friend', 'logicalboneshug') . '" href="' . wp_nonce_url(bp_loggedin_user_domain() . bp_get_friends_slug() . '/add-friend/' . $_POST['fid'], 'friends_add_friend') . '">' . __('Add Friend', 'logicalboneshug') . '</a>';
} else {
echo __("Friendship request could not be cancelled.", 'logicalboneshug');
}
} else {
echo __('Request Pending', 'logicalboneshug');
}
exit;
}