本文整理汇总了PHP中BP_Friends_Friendship::check_is_friend方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Friends_Friendship::check_is_friend方法的具体用法?PHP BP_Friends_Friendship::check_is_friend怎么用?PHP BP_Friends_Friendship::check_is_friend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BP_Friends_Friendship
的用法示例。
在下文中一共展示了BP_Friends_Friendship::check_is_friend方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: bp_friends_filter_user_query_populate_extras
/**
* Filter BP_User_Query::populate_extras to add confirmed friendship status.
*
* Each member in the user query is checked for confirmed friendship status
* against the logged-in user.
*
* @since 1.7.0
*
* @global WPDB $wpdb WordPress database access object.
*
* @param BP_User_Query $user_query The BP_User_Query object.
* @param string $user_ids_sql Comma-separated list of user IDs to fetch extra
* data for, as determined by BP_User_Query.
*/
function bp_friends_filter_user_query_populate_extras(BP_User_Query $user_query, $user_ids_sql)
{
global $wpdb;
// Stop if user isn't logged in.
if (!($user_id = bp_loggedin_user_id())) {
return;
}
$maybe_friend_ids = wp_parse_id_list($user_ids_sql);
foreach ($maybe_friend_ids as $friend_id) {
$status = BP_Friends_Friendship::check_is_friend($user_id, $friend_id);
$user_query->results[$friend_id]->friendship_status = $status;
if ('is_friend' == $status) {
$user_query->results[$friend_id]->is_friend = 1;
}
}
}
示例3: 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;
}
示例4: wpmudev_chat_buddypress_member_header_actions
function wpmudev_chat_buddypress_member_header_actions()
{
global $bp, $members_template, $wpmudev_chat, $current_user;
if ($bp->loggedin_user->id === bp_displayed_user_id()) {
return;
}
//if (!is_object('BP_Friends_Friendship')) return;
if (!bp_is_active('friends')) {
return;
}
if (!class_exists('BP_Friends_Friendship')) {
return $is_friend_ret = BP_Friends_Friendship::check_is_friend(bp_loggedin_user_id(), bp_displayed_user_id());
}
//echo "is_friend_ret[". $is_friend_ret ."]<br />";
// Set this so when we get to wp_footer it knows we need to load the JS/CSS for the Friends display.
$wpmudev_chat->_chat_plugin_settings['blocked_urls']['front'] = false;
if (BP_Friends_Friendship::check_is_friend(bp_loggedin_user_id(), bp_displayed_user_id()) == 'is_friend' || $bp->loggedin_user->is_site_admin == true) {
$content = '';
$content .= '<div id="wpmudev-chat-now-button-' . bp_displayed_user_id() . '" class="generic-button wpmudev-chat-now-button">';
$friends_status = wpmudev_chat_get_friends_status($bp->loggedin_user->id, bp_displayed_user_id());
if (!empty($friends_status[0])) {
$friends_status = $friends_status[0];
} else {
$friends_status = '';
}
$friend_data = wpmudev_chat_get_chat_status_data(bp_displayed_user_id(), $friends_status);
//echo "friend_data<pre>"; print_r($friend_data); echo "</pre>";
$friend_status_display = $friend_data['icon'] . $friend_data['label'];
if (!empty($friend_data['href'])) {
$content .= '<a class="button wpmudev-chat-button ' . $friend_data['href_class'] . '" title="' . $friend_data['href_title'] . '" href="#" rel="' . $friend_data['href'] . '">' . $friend_status_display . '</a>';
} else {
$content .= '<a onclick="return false;" disabled="disabled" class="wpmudev-chat-button ' . $friend_data['href_class'] . '" title="' . $friend_data['href_title'] . '" href="#">' . $friend_status_display . '</a>';
}
$content .= '</div>';
echo $content;
}
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: friends_check_friendship_status
/**
* Get the friendship status of two friends.
*
* Will return 'is_friends', 'not_friends', 'pending' or 'awaiting_response'.
*
* @param int $user_id ID of the first user.
* @param int $possible_friend_id ID of the other user.
* @return string Friend status of the two users.
*/
function friends_check_friendship_status($user_id, $possible_friend_id)
{
global $members_template;
// check the BP_User_Query first
// @see bp_friends_filter_user_query_populate_extras()
if (!empty($members_template->in_the_loop)) {
if (isset($members_template->member->friendship_status)) {
return $members_template->member->friendship_status;
// make sure that the friends BP_User_Query was registered before assuming
// status as 'not_friends'
} elseif (has_filter('bp_user_query_populate_extras', 'bp_friends_filter_user_query_populate_extras')) {
return 'not_friends';
}
}
return BP_Friends_Friendship::check_is_friend($user_id, $possible_friend_id);
}
示例10: bp_legacy_theme_ajax_my_get_friendship_status
function bp_legacy_theme_ajax_my_get_friendship_status()
{
// Bail if not a POST action
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
error_log("og get friendship status " . groups_get_id("students"));
$myretval = array();
// Cast gid as integer
$my_friend_ids = $_POST['fids'];
error_log("og friend status:" . print_r($my_group_ids, true));
for ($myidx = 0; $myidx < count($my_friend_ids); $myidx++) {
$my_friend_id = (int) $my_friend_ids[$myidx];
error_log("og friend id:" . $my_friend_id . " ");
$bp_loggedin_user_id = bp_loggedin_user_id();
$my_is_friend = 'is_friend' == BP_Friends_Friendship::check_is_friend($bp_loggedin_user_id, $my_friend_id);
$htmlstrtoreturn = bp_get_add_friend_button($my_friend_id, $my_is_friend);
$myretval[$my_friend_ids[$myidx]] = $htmlstrtoreturn;
}
echo json_encode($myretval);
exit;
}
示例11: buddyboss_is_my_friend
/**
* Check if the current profile a user is on is a friend or not
*
* @since BuddyBoss 2.0
*/
function buddyboss_is_my_friend($id = null)
{
global $bp;
if ($id === null) {
$id = $bp->displayed_user->id;
}
return 'is_friend' == BP_Friends_Friendship::check_is_friend($bp->loggedin_user->id, $id);
}
示例12: friends_check_friendship_status
/**
* Get the friendship status of two friends.
*
* Will return 'is_friends', 'not_friends', 'pending' or 'awaiting_response'.
*
* @since 1.2.0
*
* @param int $user_id ID of the first user.
* @param int $possible_friend_id ID of the other user.
* @return string Friend status of the two users.
*/
function friends_check_friendship_status($user_id, $possible_friend_id)
{
global $members_template;
// Check the BP_User_Query first
// @see bp_friends_filter_user_query_populate_extras().
if (!empty($members_template->in_the_loop)) {
if (isset($members_template->member->friendship_status)) {
return $members_template->member->friendship_status;
}
}
return BP_Friends_Friendship::check_is_friend($user_id, $possible_friend_id);
}
示例13: bpdd_import_users_friends
function bpdd_import_users_friends()
{
$users = bpdd_get_random_users_ids(50);
for ($con = 0, $i = 0; $i < 100; $i++) {
$user_one = $users[array_rand($users)];
$user_two = $users[array_rand($users)];
if (BP_Friends_Friendship::check_is_friend($user_one, $user_two) == 'not_friends') {
// make them friends
if (friends_add_friend($user_one, $user_two, true)) {
$con++;
}
}
}
return $con;
}
示例14: invite_anyone_group_invite_maybe_filter_invite_message
/**
* Catch the 'to' email address of sent email notifications, and hook message filter if necessary
*
* This function is necessary because the groups_notification_group_invites_message
* filter doesn't receive easily parsable info about the invitee.
*
* @since 1.0.22
*/
function invite_anyone_group_invite_maybe_filter_invite_message($to)
{
if (!bp_is_active('friends')) {
return $to;
}
$invited_user = get_user_by('email', $to);
$friendship_status = BP_Friends_Friendship::check_is_friend(bp_loggedin_user_id(), $invited_user->ID);
if ('is_friend' !== $friendship_status) {
add_action('groups_notification_group_invites_message', 'invite_anyone_group_invite_email_message', 10, 7);
}
return $to;
}
示例15: bp_displayed_user_is_friend
function bp_displayed_user_is_friend()
{
global $bp;
$friend_privacy_enable = get_option('tn_wpmu_friend_privacy_status');
$friend_privacy_redirect = get_option('tn_wpmu_friend_privacy_redirect');
if ($friend_privacy_enable == "enable") {
if (bp_is_user_activity() || bp_is_user_profile() || bp_is_user()) {
if ('is_friend' != BP_Friends_Friendship::check_is_friend($bp->loggedin_user->id, $bp->displayed_user->id) && bp_loggedin_user_id() != bp_displayed_user_id()) {
if (!is_super_admin(bp_loggedin_user_id())) {
if ($friend_privacy_redirect == '') {
bp_core_redirect($bp->root_domain);
} else {
bp_core_redirect($friend_privacy_redirect);
}
}
}
}
}
//enable
}