• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP friends_remove_friend函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中friends_remove_friend函数的典型用法代码示例。如果您正苦于以下问题:PHP friends_remove_friend函数的具体用法?PHP friends_remove_friend怎么用?PHP friends_remove_friend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了friends_remove_friend函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: friends_action_remove_friend

/**
 * Catch and process Remove Friendship requests.
 *
 * @since 1.0.1
 */
function friends_action_remove_friend()
{
    if (!bp_is_friends_component() || !bp_is_current_action('remove-friend')) {
        return false;
    }
    if (!($potential_friend_id = (int) bp_action_variable(0))) {
        return false;
    }
    if ($potential_friend_id == bp_loggedin_user_id()) {
        return false;
    }
    $friendship_status = BP_Friends_Friendship::check_is_friend(bp_loggedin_user_id(), $potential_friend_id);
    if ('is_friend' == $friendship_status) {
        if (!check_admin_referer('friends_remove_friend')) {
            return false;
        }
        if (!friends_remove_friend(bp_loggedin_user_id(), $potential_friend_id)) {
            bp_core_add_message(__('Friendship could not be canceled.', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('Friendship canceled', 'buddypress'));
        }
    } elseif ('is_friends' == $friendship_status) {
        bp_core_add_message(__('You are not yet friends with this user', 'buddypress'), 'error');
    } else {
        bp_core_add_message(__('You have a pending friendship request with this user', 'buddypress'), 'error');
    }
    bp_core_redirect(wp_get_referer());
    return false;
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:34,代码来源:bp-friends-actions.php


示例2: example_friends_ajax_addremove_friend

function example_friends_ajax_addremove_friend()
{
    global $bp;
    if ('is_friend' == BP_Friends_Friendship::check_is_friend($bp->loggedin_user->id, $_POST['fid'])) {
        if (!friends_remove_friend($bp->loggedin_user->id, $_POST['fid'])) {
            echo __('Friendship could not be canceled.', 'bp-component');
        } else {
            echo '<a id="friend-' . $_POST['fid'] . '" class="add" rel="add" title="' . __('Add Friend', 'bp-component') . '" href="' . $bp->loggedin_user->domain . $bp['friends']['slug'] . '/add-friend/' . $_POST['fid'] . '">' . __('Add Friend', 'bp-component') . '</a>';
        }
    } else {
        if ('not_friends' == BP_Friends_Friendship::check_is_friend($bp->loggedin_user->id, $_POST['fid'])) {
            if (!friends_add_friend($bp->loggedin_user->id, $_POST['fid'])) {
                echo __('Friendship could not be requested.', 'bp-component');
            } else {
                echo '<a href="' . $bp->loggedin_user->domain . $bp['friends']['slug'] . '" class="requested">' . __('Friendship Requested', 'bp-component') . '</a>';
            }
        } else {
            echo __('Request Pending', 'bp-component');
        }
    }
    return false;
}
开发者ID:natrio,项目名称:buddypress-skeleton-component,代码行数:22,代码来源:bp-example-ajax.php


示例3: test_friends_delete_activity

 /**
  * @group friends_delete_activity
  */
 public function test_friends_delete_activity()
 {
     $old_user = get_current_user_id();
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     friends_add_friend($u2, $u1);
     $friendship_id = friends_get_friendship_id($u2, $u1);
     // Set current user to u1 to accepte the friendship
     $this->set_current_user($u1);
     friends_accept_friendship($friendship_id);
     // Reset the current user
     $this->set_current_user($old_user);
     // Random activities
     $au1 = $this->factory->activity->create(array('user_id' => $u1));
     $au2 = $this->factory->activity->create(array('user_id' => $u2));
     $fc_act = bp_activity_get(array('component' => buddypress()->friends->id, 'item_id' => $friendship_id, 'filter' => array('action' => array('friendship_created')), 'show_hidden' => false));
     $this->assertTrue(count($fc_act['activities']) == 1, '1 public activity should be created when a friendship is confirmed');
     // Remove the friendship
     friends_remove_friend($u2, $u1);
     $this->assertFalse(friends_check_friendship($u2, $u1), '2 users should not be friend once the friendship is removed');
     $fd_act = bp_activity_get(array('component' => buddypress()->friends->id, 'item_id' => $friendship_id, 'filter' => array('action' => array('friendship_created')), 'show_hidden' => true));
     $this->assertTrue(count($fd_act['activities']) == 0, 'friends_delete_activity() should remove "friendship_created" activities about a deleted friendship');
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:26,代码来源:activity.php


示例4: friends_ajax_addremove_friend

function friends_ajax_addremove_friend()
{
    global $bp;
    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.", 'buddypress');
        } else {
            echo '<a id="friend-' . $_POST['fid'] . '" class="add" rel="add" title="' . __('Add Friend', 'buddypress') . '" href="' . wp_nonce_url($bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $_POST['fid'], 'friends_add_friend') . '">' . __('Add Friend', 'buddypress') . '</a>';
        }
    } else {
        if ('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.", 'buddypress');
            } else {
                echo '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '" class="requested">' . __('Friendship Requested', 'buddypress') . '</a>';
            }
        } else {
            echo __('Request Pending', 'buddypress');
        }
    }
    return false;
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:24,代码来源:bp-friends-ajax.php


示例5: bp_dtheme_ajax_addremove_friend

function bp_dtheme_ajax_addremove_friend()
{
    global $bp;
    // 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.", 'buddypress');
        } else {
            echo '<a id="friend-' . $_POST['fid'] . '" class="add" rel="add" title="' . __('Add Friend', 'buddypress') . '" href="' . nxt_nonce_url($bp->loggedin_user->domain . bp_get_friends_slug() . '/add-friend/' . $_POST['fid'], 'friends_add_friend') . '">' . __('Add Friend', 'buddypress') . '</a>';
        }
    } else {
        if ('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.", 'buddypress');
            } else {
                echo '<a href="' . $bp->loggedin_user->domain . bp_get_friends_slug() . '/requests" class="requested">' . __('Friendship Requested', 'buddypress') . '</a>';
            }
        } else {
            echo __('Request Pending', 'buddypress');
        }
    }
    return false;
}
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:28,代码来源:ajax.php


示例6: 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;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:44,代码来源:buddypress-functions.php


示例7: 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;
}
开发者ID:raminjan,项目名称:logicalbones_hug,代码行数:38,代码来源:ajax.php


示例8: friends_action_remove_friend

function friends_action_remove_friend() {
	global $bp;

	if ( $bp->current_component != $bp->friends->slug || $bp->current_action != 'remove-friend' )
		return false;

	$potential_friend_id = $bp->action_variables[0];

	if ( !is_numeric( $potential_friend_id ) || !isset( $potential_friend_id ) )
		return false;

	if ( $potential_friend_id == $bp->loggedin_user->id )
		return false;

	$friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );

	if ( 'is_friend' == $friendship_status ) {

		if ( !check_admin_referer( 'friends_remove_friend' ) )
			return false;

		if ( !friends_remove_friend( $bp->loggedin_user->id, $potential_friend_id ) ) {
			bp_core_add_message( __( 'Friendship could not be canceled.', 'buddypress' ), 'error' );
		} else {
			bp_core_add_message( __( 'Friendship canceled', 'buddypress' ) );
		}
	} else if ( 'is_friends' == $friendship_status ) {
		bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' );
	} else {
		bp_core_add_message( __( 'You have a pending friendship request with this user', 'buddypress' ), 'error' );
	}

	bp_core_redirect( wp_get_referer() );

	return false;
}
开发者ID:n-sane,项目名称:zaroka,代码行数:36,代码来源:bp-friends.php



注:本文中的friends_remove_friend函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP friends_withdraw_friendship函数代码示例发布时间:2022-05-15
下一篇:
PHP friends_reject_friendship函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap