/** * Create a new friendship. * * @since 1.0.0 * * @param int $initiator_userid ID of the "initiator" user (the user who is * sending the friendship request). * @param int $friend_userid ID of the "friend" user (the user whose friendship * is being requested). * @param bool $force_accept Optional. Whether to force acceptance. When false, * running friends_add_friend() will result in a friendship request. * When true, running friends_add_friend() will result in an accepted * friendship, with no notifications being sent. Default: false. * @return bool True on success, false on failure. */ function friends_add_friend($initiator_userid, $friend_userid, $force_accept = false) { // You cannot be friends with yourself! if ($initiator_userid == $friend_userid) { return false; } // Check if already friends, and bail if so. if (friends_check_friendship($initiator_userid, $friend_userid)) { return true; } // Setup the friendship data. $friendship = new BP_Friends_Friendship(); $friendship->initiator_user_id = $initiator_userid; $friendship->friend_user_id = $friend_userid; $friendship->is_confirmed = 0; $friendship->is_limited = 0; $friendship->date_created = bp_core_current_time(); if (!empty($force_accept)) { $friendship->is_confirmed = 1; } // Bail if friendship could not be saved (how sad!). if (!$friendship->save()) { return false; } // Send notifications. if (empty($force_accept)) { $action = 'requested'; // Update friend totals. } else { $action = 'accepted'; friends_update_friend_totals($friendship->initiator_user_id, $friendship->friend_user_id, 'add'); } /** * Fires at the end of initiating a new friendship connection. * * This is a variable hook, depending on context. * The two potential hooks are: friends_friendship_requested, friends_friendship_accepted. * * @since 1.0.0 * * @param int $id ID of the pending friendship connection. * @param int $initiator_user_id ID of the friendship initiator. * @param int $friend_user_id ID of the friend user. * @param object $friendship BuddyPress Friendship Object. */ do_action('friends_friendship_' . $action, $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship); return true; }
/** * @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'); }
function groups_ajax_invite_user() { global $bp; check_ajax_referer('groups_invite_uninvite_user'); if (!$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id']) { return false; } if (!groups_is_user_admin($bp->loggedin_user->id, $_POST['group_id'])) { return false; } if (!friends_check_friendship($bp->loggedin_user->id, $_POST['friend_id'])) { return false; } if ('invite' == $_POST['friend_action']) { if (!groups_invite_user($_POST['friend_id'], $_POST['group_id'])) { return false; } $user = new BP_Core_User($_POST['friend_id']); echo '<li id="uid-' . $user->id . '">'; echo attribute_escape($user->avatar_thumb); echo '<h4>' . attribute_escape($user->user_link) . '</h4>'; echo '<span class="activity">' . attribute_escape($user->last_active) . '</span>'; echo '<div class="action"> <a class="remove" href="' . wp_nonce_url($bp->loggedin_user->domain . $bp->groups->slug . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user') . '" id="uid-' . attribute_escape($user->id) . '">' . __('Remove Invite', 'buddypress') . '</a> </div>'; echo '</li>'; } else { if ('uninvite' == $_POST['friend_action']) { if (!groups_uninvite_user($_POST['friend_id'], $_POST['group_id'])) { return false; } return true; } else { return false; } } }
/** * Create a new friendship. * * @param int $initiator_userid ID of the "initiator" user (the user who is * sending the friendship request). * @param int $friend_userid ID of the "friend" user (the user whose friendship * is being requested). * @param bool $force_accept Optional. Whether to force acceptance. When false, * running friends_add_friend() will result in a friendship request. * When true, running friends_add_friend() will result in an accepted * friendship, with no notifications being sent. Default: false. * @return bool True on success, false on failure. */ function friends_add_friend($initiator_userid, $friend_userid, $force_accept = false) { // You cannot be friends with yourself! if ($initiator_userid == $friend_userid) { return false; } // Check if already friends, and bail if so if (friends_check_friendship($initiator_userid, $friend_userid)) { return true; } // Setup the friendship data $friendship = new BP_Friends_Friendship(); $friendship->initiator_user_id = $initiator_userid; $friendship->friend_user_id = $friend_userid; $friendship->is_confirmed = 0; $friendship->is_limited = 0; $friendship->date_created = bp_core_current_time(); if (!empty($force_accept)) { $friendship->is_confirmed = 1; } // Bail if friendship could not be saved (how sad!) if (!$friendship->save()) { return false; } // Send notifications if (empty($force_accept)) { $action = 'friends_friendship_requested'; // Update friend totals } else { $action = 'friends_friendship_accepted'; friends_update_friend_totals($friendship->initiator_user_id, $friendship->friend_user_id, 'add'); } // Call the above titled action and pass friendship data into it do_action($action, $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship); return true; }
/** * Invites a friend to join a group via a POST request. * * @return unknown * @since BuddyPress (1.2) * @todo Audit return types */ function bp_dtheme_ajax_invite_user() { // Bail if not a POST action if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) { return; } check_ajax_referer('groups_invite_uninvite_user'); if (!$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id']) { return; } if (!bp_groups_user_can_send_invites($_POST['group_id'])) { return; } if (!friends_check_friendship(bp_loggedin_user_id(), $_POST['friend_id'])) { return; } if ('invite' == $_POST['friend_action']) { if (!groups_invite_user(array('user_id' => $_POST['friend_id'], 'group_id' => $_POST['group_id']))) { return; } $user = new BP_Core_User($_POST['friend_id']); echo '<li id="uid-' . $user->id . '">'; echo $user->avatar_thumb; echo '<h4>' . $user->user_link . '</h4>'; echo '<span class="activity">' . esc_attr($user->last_active) . '</span>'; echo '<div class="action"> <a class="button remove" href="' . wp_nonce_url(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user') . '" id="uid-' . esc_attr($user->id) . '">' . __('Remove Invite', 'logicalboneshug') . '</a> </div>'; echo '</li>'; exit; } elseif ('uninvite' == $_POST['friend_action']) { if (!groups_uninvite_user($_POST['friend_id'], $_POST['group_id'])) { return; } exit; } else { return; } }
/** * Render the navigation markup for the logged-in user. * * Each component adds to this navigation array within its own * [component_name]setup_nav() function. * * This navigation array is the top level navigation, so it contains items such as: * [Blog, Profile, Messages, Groups, Friends] ... * * The function will also analyze the current component the user is in, to * determine whether or not to highlight a particular nav item. * * @todo Move to a back-compat file? * @deprecated Does not seem to be called anywhere in BP core. */ function bp_get_loggedin_user_nav() { $bp = buddypress(); // Loop through each navigation item. foreach ((array) $bp->bp_nav as $nav_item) { $selected = ''; // If the current component matches the nav item id, then add a highlight CSS class. if (!bp_is_directory() && !empty($bp->active_components[bp_current_component()]) && $bp->active_components[bp_current_component()] == $nav_item['css_id']) { $selected = ' class="current selected"'; } // If we are viewing another person (current_userid does not equal // loggedin_user->id then check to see if the two users are friends. // if they are, add a highlight CSS class to the friends nav item // if it exists. if (!bp_is_my_profile() && bp_displayed_user_id()) { $selected = ''; if (bp_is_active('friends')) { if ($nav_item['css_id'] == $bp->friends->id) { if (friends_check_friendship(bp_loggedin_user_id(), bp_displayed_user_id())) { $selected = ' class="current selected"'; } } } } // Echo out the final list item. echo apply_filters_ref_array('bp_get_loggedin_user_nav_' . $nav_item['css_id'], array('<li id="li-nav-' . $nav_item['css_id'] . '" ' . $selected . '><a id="my-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>', &$nav_item)); } // Always add a log out list item to the end of the navigation. $logout_link = '<li><a id="wp-logout" href="' . wp_logout_url(bp_get_root_domain()) . '">' . __('Log Out', 'buddypress') . '</a></li>'; echo apply_filters('bp_logout_nav_link', $logout_link); }
/** * Checks if the user can get the link of an item * * @param array $privacy the sharing options * @uses buddydrive_get_owner_id() to get owner's id * @uses bp_loggedin_user_id() to get current user id * @uses is_user_logged_in() to check if the visitor is not logged in * @uses bp_is_active() to check for friends and groups component * @uses friends_check_friendship() to check the friendship between owner and current user * @uses groups_is_user_member() to check if the current user is member of the group the BuddyDrive item is attached to * @return boolean true or false */ function buddydrive_current_user_can_link($privacy = false) { $can_link = false; if (buddydrive_get_owner_id() == bp_loggedin_user_id()) { $can_link = true; } else { if (empty($privacy)) { $can_link = false; } else { if (!is_user_logged_in()) { $can_link = false; } else { if ($privacy['privacy'] == 'public') { $can_link = true; } else { if ($privacy['privacy'] == 'friends' && bp_is_active('friends') && friends_check_friendship(buddydrive_get_owner_id(), bp_loggedin_user_id())) { $can_link = true; } else { if ($privacy['privacy'] == 'groups' && bp_is_active('groups') && !empty($privacy['group']) && groups_is_user_member(bp_loggedin_user_id(), intval($privacy['group']))) { $can_link = true; } else { if (is_super_admin()) { $can_link = true; } } } } } } } return apply_filters('buddydrive_current_user_can_link', $can_link); }
function get_status_sql($link_owner_user_id = false, $format_string = '%s') { global $bp; // if user is the site admin or is logged in and viewing their own links, then no limitations if (is_super_admin() || bp_is_my_profile()) { // return an empty string return ''; } else { // everyone can see the public links $status_opts = array(self::STATUS_PUBLIC); // if logged in user is a friend, show friends only links too if (bp_links_is_friends_enabled()) { if ($link_owner_user_id && $link_owner_user_id != $bp->loggedin_user->id && friends_check_friendship($link_owner_user_id, $bp->loggedin_user->id)) { $status_opts[] = self::STATUS_FRIENDS; } } // return the sql string return sprintf($format_string, sprintf('status IN (%s)', join(',', $status_opts))); } }
/** * Evaluates current visitor and determines what a vistor is relative to various biz rules. these "flags" are used for managing editability and visibility. */ public function ez_bp_profile_current_visitor_is($int_compare_to_user_id = '') { global $bp; // start with nothing $arr_visitor_is = array(); // EVERY visitor gets to see public - if there is any public $arr_visitor_is['public'] = true; /** * If the visitor is not loggedin then all other checks are irrelevant; so save time and return if not logged in. */ if (is_user_logged_in()) { $arr_visitor_is['loggedin'] = true; } else { return $arr_visitor_is; } // now that we're sure we have a logged in visitor use the $bp global to work some magic $int_loggedin_user_id = $bp->loggedin_user->id; $int_displayed_user_id = $bp->displayed_user->id; /** * fyi - did you notice, we're going to allow a user id to be passed in and used for the current loggedin user. * we don't really need this now per se, but it made sense to bake it in for later, just in case. */ if (is_int($int_compare_to_user_id)) { $int_displayed_user_id = $int_compare_to_user_id; } /** * what if you want more layers in your organization? then you only have to customize this one method. */ $arr_visitor_is_custom = $this->ez_bp_profile_current_visitor_is_custom($int_compare_to_user_id = ''); // if we get an array back then merge it in if (is_array($arr_visitor_is_custom)) { $arr_visitor_is = array_merge($arr_visitor_is, $arr_visitor_is_custom); } // if the loggedin user is the display / compare to user then set the user flag and return 'cause checking friends and groups doesn't make sense. if ($int_loggedin_user_id == $int_displayed_user_id) { $arr_visitor_is['user'] = true; return $arr_visitor_is; } if (bp_is_active('friends')) { if (friends_check_friendship($int_displayed_user_id, $int_loggedin_user_id)) { $arr_visitor_is['friends'] = true; } } if (bp_is_active('groups')) { // does the current (loggedin) visitor share any groups with the profile'd person? if ($int_loggedin_user_id != $int_displayed_user_id) { $arr_displayed_user_id_groups = BP_Groups_Member::get_group_ids($int_displayed_user_id); $arr_loggedin_user_id_groups = BP_Groups_Member::get_group_ids($int_loggedin_user_id); $arr_intersect_groups = array_intersect($arr_displayed_user_id_groups['groups'], $arr_loggedin_user_id_groups['groups']); // intersect means the users have a group(s) in common if (!empty($arr_intersect_groups)) { $arr_visitor_is['groups'] = true; } } } return $arr_visitor_is; }
/** * The selection query * * @param array $args arguments to customize the query * @uses wp_parse_args() to merge args with defaults one * @uses bp_displayed_user_id() to get the displayed user id * @uses bp_is_my_profile() to check if we're on current user profile * @uses bp_is_active() to check for groups and friends component * @uses friends_check_friendship() to check if current user is friend with item owner * @uses friends_get_friend_user_ids() to get the friends of current user * @uses paginate_links() * @uses add_query_arg() */ public function get($args) { // Only run the query once if (empty($this->query)) { $defaults = array('id' => false, 'name' => false, 'group_id' => false, 'user_id' => false, 'per_page' => 10, 'paged' => 1, 'type' => false, 'buddydrive_scope' => false, 'search' => false, 'buddydrive_parent' => 0, 'exclude' => false, 'orderby' => 'title', 'order' => 'ASC'); $r = wp_parse_args($args, $defaults); $paged = !empty($_POST['page']) ? intval($_POST['page']) : $r['paged']; if (!empty($r['id'])) { $query_args = array('post_status' => 'publish', 'post_type' => $r['type'], 'p' => $r['id'], 'posts_per_page' => $r['per_page'], 'paged' => $paged); } else { if (!empty($r['name']) && !empty($r['type'])) { $query_args = array('post_status' => 'publish', 'post_type' => $r['type'], 'name' => $r['name'], 'posts_per_page' => $r['per_page'], 'paged' => $paged); } else { $query_args = array('post_status' => 'publish', 'post_type' => $r['type'], 'post_parent' => $r['buddydrive_parent'], 'posts_per_page' => $r['per_page'], 'paged' => $paged, 'orderby' => $r['orderby'], 'order' => $r['order'], 'meta_query' => array()); switch ($r['buddydrive_scope']) { case 'files': if (!empty($r['user_id']) && (int) $r['user_id'] === (int) bp_displayed_user_id()) { $query_args['author'] = $r['user_id']; } if (!bp_is_my_profile() && !bp_current_user_can('bp_moderate')) { $privacy = array('private'); if (bp_is_active('friends') && !friends_check_friendship($r['user_id'], bp_loggedin_user_id())) { $privacy[] = 'friends'; } $query_args['meta_query'][] = array('key' => '_buddydrive_sharing_option', 'value' => $privacy, 'compare' => 'NOT IN'); } break; case 'friends': if (bp_is_active('friends')) { $ids = friends_get_friend_user_ids(bp_loggedin_user_id()); if (!empty($ids)) { $query_args['author'] = implode(',', $ids); $query_args['meta_query'][] = array('key' => '_buddydrive_sharing_option', 'value' => 'friends', 'compare' => '='); } else { // we need to use a dummy query to avoid listing all files ! $query_args['meta_query'][] = array('key' => '_buddydrive_sharing_option', 'value' => 'dummyvalue', 'compare' => '='); } } break; case 'groups': if (bp_is_active('groups') && !empty($r['group_id']) && empty($r['buddydrive_parent'])) { $query_args['meta_query'][] = array('key' => '_buddydrive_sharing_groups', 'value' => $r['group_id'], 'compare' => 'IN'); } break; case 'admin': if (!empty($r['user_id'])) { $query_args['author'] = $r['user_id']; } if (bp_is_active('groups') && !empty($r['group_id']) && empty($r['buddydrive_parent'])) { $query_args['meta_query'][] = array('key' => '_buddydrive_sharing_groups', 'value' => $r['group_id'], 'compare' => 'IN'); } // Search is only possible for Super Admin, as searching makes it difficult to garanty privacy if (!empty($r['search'])) { $query_args['s'] = $r['search']; } break; default: // non public meta values are restricted to admins if ('public' !== $r['buddydrive_scope'] && !bp_current_user_can('bp_moderate')) { $meta_value = 'dummyvalue'; } else { $meta_value = $r['buddydrive_scope']; } /** * Use the scope to build a meta query * * if the scope match a sharing option, files or folders will be fetched */ $query_args['meta_query'][] = array('key' => '_buddydrive_sharing_option', 'value' => $meta_value, 'compare' => '='); } } } if (!empty($r['exclude'])) { if (!is_array($r['exclude'])) { $r['exclude'] = explode(',', $r['exclude']); } $query_args['post__not_in'] = $r['exclude']; } /** * Use the 'buddydrive_item_get' filter to customize the query args * * @since 1.3.2 * * @param array $query_args the arguments for the BuddyDrive query * @param array $r the requested arguments */ $this->query = new WP_Query(apply_filters('buddydrive_item_get', $query_args, $r)); // Let's also set up some pagination $this->pag_links = paginate_links(array('base' => add_query_arg('items_page', '%#%'), 'format' => '', 'total' => ceil((int) $this->query->found_posts / (int) $this->query->query_vars['posts_per_page']), 'current' => (int) $paged, 'prev_text' => '←', 'next_text' => '→', 'mid_size' => 1)); } }
/** * Invites a friend to join a group via a POST request. * * @since BuddyPress (1.2) * @todo Audit return types */ function bp_legacy_theme_ajax_invite_user() { // Bail if not a POST action if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) { return; } check_ajax_referer('groups_invite_uninvite_user'); if (!$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id']) { return; } if (!bp_groups_user_can_send_invites($_POST['group_id'])) { return; } if (!friends_check_friendship(bp_loggedin_user_id(), $_POST['friend_id'])) { return; } $group_id = (int) $_POST['group_id']; $friend_id = (int) $_POST['friend_id']; if ('invite' == $_POST['friend_action']) { $group = groups_get_group($group_id); // Users who have previously requested membership do not need // another invitation created for them if (BP_Groups_Member::check_for_membership_request($friend_id, $group_id)) { $user_status = 'is_pending'; // Create the user invitation } elseif (groups_invite_user(array('user_id' => $friend_id, 'group_id' => $group_id))) { $user_status = 'is_invited'; // Miscellaneous failure } else { return; } $user = new BP_Core_User($friend_id); $uninvite_url = bp_is_current_action('create') ? bp_get_groups_directory_permalink() . 'create/step/group-invites/?user_id=' . $friend_id : bp_get_group_permalink($group) . 'send-invites/remove/' . $friend_id; echo '<li id="uid-' . esc_attr($user->id) . '">'; echo $user->avatar_thumb; echo '<h4>' . $user->user_link . '</h4>'; echo '<span class="activity">' . esc_attr($user->last_active) . '</span>'; echo '<div class="action"> <a class="button remove" href="' . wp_nonce_url($uninvite_url, 'groups_invite_uninvite_user') . '" id="uid-' . esc_attr($user->id) . '">' . __('Remove Invite', 'buddypress') . '</a> </div>'; if ('is_pending' == $user_status) { echo '<p class="description">' . sprintf(__('%s has previously requested to join this group. Sending an invitation will automatically add the member to the group.', 'buddypress'), $user->user_link) . '</p>'; } echo '</li>'; exit; } elseif ('uninvite' == $_POST['friend_action']) { // Users who have previously requested membership should not // have their requests deleted on the "uninvite" action if (BP_Groups_Member::check_for_membership_request($friend_id, $group_id)) { return; } // Remove the unsent invitation if (!groups_uninvite_user($friend_id, $group_id)) { return; } exit; } else { return; } }
/** * Get the ids of fields that are hidden for this displayed/loggedin user pair * * This is the function primarily responsible for profile field visibility. It works by determining * the relationship between the displayed_user (ie the profile owner) and the current_user (ie the * profile viewer). Then, based on that relationship, we query for the set of fields that should * be excluded from the profile loop. * * @since 1.6 * @see BP_XProfile_Group::get() * @uses apply_filters() Filter bp_xprofile_get_hidden_fields_for_user to modify visibility levels, * or if you have added your own custom levels * * @param int $displayed_user_id The id of the user the profile fields belong to * @param int $current_user_id The id of the user viewing the profile * @return array An array of field ids that should be excluded from the profile query */ function bp_xprofile_get_hidden_fields_for_user($displayed_user_id = 0, $current_user_id = 0) { if (!$displayed_user_id) { $displayed_user_id = bp_displayed_user_id(); } if (!$displayed_user_id) { return array(); } if (!$current_user_id) { $current_user_id = bp_loggedin_user_id(); } // @todo - This is where you'd swap out for current_user_can() checks if ($current_user_id) { // Current user is logged in if ($displayed_user_id == $current_user_id) { // If you're viewing your own profile, nothing's private $hidden_fields = array(); } else { if (bp_is_active('friends') && friends_check_friendship($displayed_user_id, $current_user_id)) { // If the current user and displayed user are friends, show all $hidden_fields = array(); } else { // current user is logged-in but not friends, so exclude friends-only $hidden_levels = array('friends'); $hidden_fields = bp_xprofile_get_fields_by_visibility_levels($displayed_user_id, $hidden_levels); } } } else { // Current user is not logged in, so exclude friends-only and loggedin $hidden_levels = array('friends', 'loggedin'); $hidden_fields = bp_xprofile_get_fields_by_visibility_levels($displayed_user_id, $hidden_levels); } return apply_filters('bp_xprofile_get_hidden_fields_for_user', $hidden_fields, $displayed_user_id, $current_user_id); }
/** * Get the visibility levels that should be hidden for this user pair * * Field visibility is determined based on the relationship between the * logged-in user, the displayed user, and the visibility setting for the * current field. (See bp_xprofile_get_hidden_fields_for_user().) This * utility function speeds up this matching by fetching the visibility levels * that should be hidden for the current user pair. * * @since BuddyPress (1.8.2) * @see bp_xprofile_get_hidden_fields_for_user() * * @param int $displayed_user_id The id of the user the profile fields belong to * @param int $current_user_id The id of the user viewing the profile * @return array An array of visibility levels hidden to the current user */ function bp_xprofile_get_hidden_field_types_for_user($displayed_user_id = 0, $current_user_id = 0) { // Current user is logged in if (!empty($current_user_id)) { // Nothing's private when viewing your own profile, or when the // current user is an admin if ($displayed_user_id == $current_user_id || bp_current_user_can('bp_moderate')) { $hidden_levels = array(); // If the current user and displayed user are friends, show all } elseif (bp_is_active('friends') && friends_check_friendship($displayed_user_id, $current_user_id)) { $hidden_levels = array('adminsonly'); // current user is logged in but not friends, so exclude friends-only } else { $hidden_levels = array('friends', 'adminsonly'); } // Current user is not logged in, so exclude friends-only, loggedin, and adminsonly. } else { $hidden_levels = array('friends', 'loggedin', 'adminsonly'); } return apply_filters('bp_xprofile_get_hidden_field_types_for_user', $hidden_levels, $displayed_user_id, $current_user_id); }
/** * Filter the members loop to show muted friends. * * @since 1.0.0 * * @param array $r Arguments for changing the contents of the loop. * @return array */ function bp_mute_filter_members_friends($r) { if (!bp_is_active('friends')) { return $r; } if (bp_is_current_component('mute') && bp_is_current_action('friends')) { $ids = Mute::get_muting(bp_displayed_user_id()); foreach ($ids as $id) { $result = friends_check_friendship(bp_displayed_user_id(), $id); if ($result) { $array[] = $id; } } if (empty($array)) { $r['include'] = 0; } else { $r['include'] = $array; } } return $r; }
/** * Generate content for our picture grid * * @since BuddyBoss 2.0 * @todo Update the theme file (members/single/pictures.php) and create a Wordpress like loop for the images e.g. <?php if ( buddyboss_picgrid_has_pics() ): while( buddyboss_picgrid_has_pics() ): ?> <?php buddyboss_picgrid_thumbnail(); ?> - and - <a href="<?php buddyboss_picgrid_fullsize_url(); ?>" title="<?php buddyboss_picgrid_image_title(); ?>"> <img src="<?php buddyboss_picgrid_thumbnail_url(); ?>" width="<?php buddyboss_picgrid_thumbnail_width(); ?>" height="<?php buddyboss_picgrid_thumbnail_height(); ?>" /> </a> <?php endwhile; endif; ?> (need to rename these for clarity, I think they're too long (JP)) * functions to create: buddyboss_picgrid_has_pics() For the if/while Wordpress style loop buddyboss_picgrid_attachment_id() Returns the ID of the current image buddyboss_picgrid_thumbnail() Echo '<li><a><img>' tags for you of the current thumbnail buddyboss_picgrid_thumbnail_url() Echos the url location of the current thumbnail get_buddyboss_picgrid_thumbnail_url() Returns the url location of the current thumbnail buddyboss_picgrid_thumbnail_width() Echos the current thumbnail width get_buddyboss_picgrid_thumbnail_width() Returns the current thumbnail width buddyboss_picgrid_thumbnail_height() Echos the current thumbnail height get_buddyboss_picgrid_thumbnail_height() Returns the current thumbnail height buddyboss_picgrid_fullsize_url() Echos the url location of the current full size image get_buddyboss_picgrid_fullsize_url() Returns the url location of the current thumbnail buddyboss_picgrid_fullsize_width() Echos the current full size image width get_buddyboss_picgrid_fullsize_width() Returns the current full size image width buddyboss_picgrid_fullsize_height() Echos the current full size image height get_buddyboss_picgrid_fullsize_height() Returns the current full size image height */ function buddyboss_pics_screen_picture_grid_content() { global $bp, $wpdb, $buddyboss_pics; $wpdb->show_errors = BUDDYBOSS_DEBUG; //$img_size = is_active_sidebar( 'Profile' ) ? 'buddyboss_pic_med' : 'buddyboss_pic_wide'; $img_size = 'buddyboss_pic_wide'; $gallery_class = is_active_sidebar('Profile') ? 'gallery has-sidebar' : 'gallery'; $user_id = $bp->displayed_user->id; $activity_table = bp_core_get_table_prefix() . 'bp_activity'; $activity_meta_table = bp_core_get_table_prefix() . 'bp_activity_meta'; $groups_table = bp_core_get_table_prefix() . 'bp_groups'; $pages_sql = "SELECT COUNT(*) FROM {$activity_table} a\n\t\t\t\t\t\t\t\tINNER JOIN {$activity_meta_table} am ON a.id = am.activity_id\n\t\t\t\t\t\t\t\tLEFT JOIN (SELECT activity_id, meta_key, meta_value FROM {$activity_meta_table}\n\t\t\t\t\t\t\t\t WHERE meta_key = 'activityprivacy') am2 ON a.id = am2.activity_id\n\t\t\t\t\t\t\t\tLEFT JOIN (SELECT id FROM {$groups_table} WHERE status != 'public' ) grp ON a.item_id = grp.id\n\t\t\t\t\t\t\t\tWHERE a.user_id = {$user_id}\n\t\t\t\t\t\t\t\tAND (am.meta_key = 'buddyboss_pics_aid' OR am.meta_key = 'bboss_pics_aid')\n\t\t\t\t\t\t\t\tAND (a.component != 'groups' || a.item_id != grp.id)"; $buddyboss_pics->grid_num_pics = $wpdb->get_var($pages_sql); $buddyboss_pics->grid_current_page = isset($_GET['page']) ? (int) $_GET['page'] : 1; // Prepare a SQL query to retrieve the activity posts // that have pictures associated with them $sql = "SELECT a.*, am.meta_value, am2.meta_value as privacy FROM {$activity_table} a\n\t\t\t\t\tINNER JOIN {$activity_meta_table} am ON a.id = am.activity_id\n\t\t\t\t\tLEFT JOIN (SELECT activity_id, meta_key, meta_value FROM {$activity_meta_table}\n\t\t\t\t\t WHERE meta_key = 'activityprivacy') am2 ON a.id = am2.activity_id\n\t\t\t\t\tLEFT JOIN (SELECT id FROM {$groups_table} WHERE status != 'public' ) grp ON a.item_id = grp.id\n\t\t\t\t\tWHERE a.user_id = {$user_id}\n\t\t\t\t\tAND (am.meta_key = 'buddyboss_pics_aid' OR am.meta_key = 'bboss_pics_aid')\n\t\t\t\t\tAND (a.component != 'groups' || a.item_id != grp.id)\n\t\t\t\t\tORDER BY a.date_recorded DESC"; buddyboss_log("SQL: {$sql}"); $pics = $wpdb->get_results($sql, ARRAY_A); $buddyboss_pics->grid_pagination = new BuddyBoss_Paginated($pics, $buddyboss_pics->grid_pics_per_page, $buddyboss_pics->grid_current_page); buddyboss_log("RESULT: {$pics}"); // If we have results let's print out a simple grid if (!empty($pics)) { $buddyboss_pics->grid_had_pics = true; $buddyboss_pics->grid_num_pics = count($pics); /** * DEBUG */ // echo '<br/><br/><div style="display:block;background:#f0f0f0;border:2px solid #ccc;margin:20px;padding:15px;color:#333;"><pre>'; // var_dump( $pics ); // echo '</pre></div><hr/><br/><br/><br/><br/>'; // die; /**/ $html_grid = '<ul class="' . $gallery_class . '" id="buddyboss-pics-grid">' . "\n"; foreach ($pics as $pic) { /** * DEBUG */ // echo '<br/><br/><div style="display:block;background:#f0f0f0;border:2px solid #ccc;margin:20px;padding:15px;color:#333;"><pre>'; // var_dump( bp_activity_get_permalink($pic['id']), $pic ); // echo '</pre></div><hr/><br/><br/><br/><br/>'; // die; /**/ //BP ACTIVITY PRIVACY FIX if (function_exists('bp_activity_privacy_add_js')) { $is_super_admin = is_super_admin(); $bp_displayed_user_id = bp_displayed_user_id(); $bp_loggedin_user_id = bp_loggedin_user_id(); if ($pic['privacy'] == 'loggedin' && !$bp_loggedin_user_id) { continue; } if ($pic['privacy'] == 'friends' && !friends_check_friendship($bp_loggedin_user_id, $bp_displayed_user_id) && $bp_loggedin_user_id != $bp_displayed_user_id) { continue; } if ($pic['privacy'] == 'groupfriends' && !friends_check_friendship($bp_loggedin_user_id, $bp_displayed_user_id || !groups_is_user_member($bp_loggedin_user_id, $bp_displayed_user_id))) { continue; } if ($pic['privacy'] == 'grouponly' && !groups_is_user_member($bp_loggedin_user_id, $bp_displayed_user_id)) { continue; } if ($pic['privacy'] == 'groupmoderators' && !groups_is_user_mod($bp_loggedin_user_id, $bp_displayed_user_id)) { continue; } if ($pic['privacy'] == 'groupadmins' && !groups_is_user_admin($bp_loggedin_user_id, $bp_displayed_user_id)) { continue; } if ($pic['privacy'] == 'adminsonly' && !$is_super_admin) { continue; } if ($pic['privacy'] == 'onlyme' && $bp_loggedin_user_id != $bp_displayed_user_id) { continue; } } $attachment_id = isset($pic['meta_value']) ? (int) $pic['meta_value'] : 0; // Make sure we have a valid attachment ID if ($attachment_id > 0) { // Let's get the permalink of this attachment to show within a lightbox $permalink = bp_activity_get_permalink($pic['id']); $ajax_link = rtrim($permalink, '/') . '/?buddyboss_ajax_pic=true'; // Let's get the caption $action = ''; if (bp_has_activities('include=' . $pic['id'])) { while (bp_activities()) { bp_the_activity(); $action = '<div class="buddyboss_pics_action">' . bp_get_activity_action() . '</div>'; } } // Grab the image details $image = wp_get_attachment_image_src($attachment_id, $img_size); // grab the thumbnail details $tn = wp_get_attachment_image_src($attachment_id, 'buddyboss_pic_tn'); if (is_array($tn) && !empty($tn) && isset($tn[0]) && $tn[0] != '') { $buddyboss_pics->grid_data[] = array('attachment' => $attachment_id, 'action' => $action, 'image' => $image, 'tn' => $tn, 'permalink' => $permalink, 'ajaxlink' => $ajax_link); $html_grid .= '<li class="gallery-item"><div><a rel="gal_item" href="' . $image[0] . '"><img src="' . $tn[0] . '" width="' . $tn[1] . '" height="' . $tn[2] . '" /></a></div></li>' . "\n"; } } } $html_grid .= '</ul>' . "\n\n"; $buddyboss_pics->grid_html = $html_grid; $buddyboss_pics->grid_has_pics = true; } else { $buddyboss_pics->grid_has_pics = false; $buddyboss_pics->grid_num_pics = 0; $buddyboss_pics->grid_current_pic = null; $buddyboss_pics->grid_data = array(); $buddyboss_pics->grid_html = null; } }
/** * Opens a folder and list the files attach to it depending on its privacy * * @uses buddydrive_get_buddyfile() to get the folder * @uses buddydrive_get_folder_post_type() to get the folder post type * @uses bp_is_active() to check if friends or groups components are actives * @uses friends_check_friendship() to check if current user is a friend of the folder owner * @uses groups_is_user_member() to check if the user is a member of the group the folder is attached to * @uses buddydrive_get_template() to get the template for bp-default or any theme * @return string the list of files */ function buddydrive_open_buddyfolder() { // Bail if not a POST action if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) { return; } $buddyfolder_id = $_POST['folder']; $buddyfolder = buddydrive_get_buddyfile($buddyfolder_id, buddydrive_get_folder_post_type()); $result = array(); $access = false; $buddyscope = $_POST['scope']; if (empty($buddyfolder->ID)) { $result[] = '<tr id="no-buddyitems"><td colspan="5"><div id="message" class="info"><p>' . __('Sorry, this folder does not exist anymore.', 'buddydrive') . '</p></div></td></tr>'; } else { switch ($buddyfolder->check_for) { case 'private': $access = $buddyfolder->user_id == bp_loggedin_user_id() ? true : false; break; case 'public': $access = true; break; case 'password': $access = true; break; case 'friends': if (bp_is_active('friends') && friends_check_friendship($buddyfolder->user_id, bp_loggedin_user_id()) || $buddyfolder->user_id == bp_loggedin_user_id()) { $access = true; } else { $access = false; } break; case 'groups': if (bp_is_active('groups') && groups_is_user_member(bp_loggedin_user_id(), intval($buddyfolder->group))) { $access = true; } else { if ($buddyfolder->user_id == bp_loggedin_user_id()) { $access = true; } else { if (is_super_admin()) { $access = true; } else { $access = false; } } } break; } if (!empty($access) || bp_current_user_can('bp_moderate')) { ob_start(); bp_get_template_part('buddydrive-loop'); $result[] = ob_get_contents(); ob_end_clean(); } else { $result[] = '<tr id="no-access"><td colspan="5"><div id="message" class="info"><p>' . __('Sorry, this folder is private', 'buddydrive') . '</p></div></td></tr>'; } $name_required = !empty($_POST['foldername']) ? 1 : 0; if (!empty($name_required)) { $result[] = $buddyfolder->title; } } echo json_encode($result); die; }
/** * Get the visibility levels that should be hidden for this user pair * * Field visibility is determined based on the relationship between the * logged-in user, the displayed user, and the visibility setting for the * current field. (See bp_xprofile_get_hidden_fields_for_user().) This * utility function speeds up this matching by fetching the visibility levels * that should be hidden for the current user pair. * * @since BuddyPress (1.8.2) * @see bp_xprofile_get_hidden_fields_for_user() * * @param int $displayed_user_id The id of the user the profile fields belong to * @param int $current_user_id The id of the user viewing the profile * @return array An array of visibility levels hidden to the current user */ function bp_xprofile_get_hidden_field_types_for_user($displayed_user_id = 0, $current_user_id = 0) { // Current user is logged in if (!empty($current_user_id)) { // Nothing's private when viewing your own profile, or when the // current user is an admin if ($displayed_user_id == $current_user_id || bp_current_user_can('bp_moderate')) { $hidden_levels = array(); // If the current user and displayed user are friends, show all } elseif (bp_is_active('friends') && friends_check_friendship($displayed_user_id, $current_user_id)) { $hidden_levels = array('adminsonly'); // current user is logged in but not friends, so exclude friends-only } else { $hidden_levels = array('friends', 'adminsonly'); } // Current user is not logged in, so exclude friends-only, loggedin, and adminsonly. } else { $hidden_levels = array('friends', 'loggedin', 'adminsonly'); } /** * Filters the visibility levels that should be hidden for this user pair. * * @since BuddyPress (2.0.0) * * @param array $hidden_fields Array of hidden fields for the displayed/logged in user. * @param int $displayed_user_id ID of the displayed user. * @param int $current_user_id ID of the current user. */ return apply_filters('bp_xprofile_get_hidden_field_types_for_user', $hidden_levels, $displayed_user_id, $current_user_id); }
/** * bp_album_privacy_level_permitted() * * @version 0.1.8.12 * @since 0.1.8.0 */ function bp_album_privacy_level_permitted() { global $bp; if (!is_user_logged_in()) { return 0; } elseif (is_super_admin()) { return 10; } elseif ($bp->displayed_user->id && $bp->displayed_user->id == $bp->loggedin_user->id) { return 6; } elseif ($bp->displayed_user->id && function_exists('friends_check_friendship') && friends_check_friendship($bp->displayed_user->id, $bp->loggedin_user->id)) { return 4; } else { return 2; } }
function bp_links_is_link_visibile($link_id_or_obj, $user_id = null) { global $bp; // owners and site admins can always see the link if ($bp->is_item_admin) { return true; } if ($link_id_or_obj instanceof BP_Links_Link) { $link = $link_id_or_obj; } else { $link = new BP_Links_Link($link_id_or_obj); } if (empty($user_id) && is_user_logged_in()) { $user_id = $bp->loggedin_user->id; } // who else can see this link? // check friendship last because of DB hit switch ($link->status) { case BP_Links_Link::STATUS_PUBLIC: return true; case BP_Links_Link::STATUS_HIDDEN: return false; case BP_Links_Link::STATUS_FRIENDS: return $user_id && bp_links_is_friends_enabled() ? friends_check_friendship($user_id, $link->user_id) : false; default: return false; } }
function bp_profile_wire_can_post() { global $bp; if (bp_is_home()) { return true; } if (function_exists('friends_install')) { if (friends_check_friendship($bp->loggedin_user->id, $bp->displayed_user->id)) { return true; } else { return false; } } return true; }
/** * Manages file downloads based on the privacy of the file/folder * * @uses bp_displayed_user_id() to be sure we're not on a profile * @uses bp_is_current_component() to check for BuddyDrive component * @uses bp_current_action() to check if current action is file / folder * @uses esc_url() * @uses wp_get_referer() to eventually redirect the user * @uses bp_action_variable() to get the name of the file / folder * @uses buddydrive_get_buddyfile() to get the file / folder object * @uses buddydrive_get_folder_post_type() to get the folder post type * @uses bp_loggedin_user_id() to get current user id * @uses is_super_admin() as super admin can download anything * @uses bp_core_add_message() to eventually display a warning message to user * @uses buddydrive_get_user_buddydrive_url() to construct the user's BuddyDrive url * @uses bp_core_redirect() to redirect user if needed * @uses friends_check_friendship() to check if the current user is friend with the file owner * @uses bp_is_active() to check a BuddyPress component is active * @uses groups_is_user_member() to check if the current user is member of the group of the file * @uses groups_get_group() to get the group object of the group the file / folder is attached to * @uses bp_get_group_permalink() to build the group link * @uses buddydrive_get_group_buddydrive_url() to build the link to the BuddyDrive of the group * @uses site_url() to redirect to home if nothing match * @return binary the file! (or redirects to the folder) */ function buddydrive_file_downloader() { if (!bp_displayed_user_id() && bp_is_current_component('buddydrive') && 'file' == bp_current_action()) { $redirect = esc_url(wp_get_referer()); $buddyfile_name = bp_action_variable(0); $buddydrive_file = buddydrive_get_buddyfile($buddyfile_name); if (empty($buddydrive_file)) { bp_core_add_message(__('OOps, we could not find your file.', 'buddydrive'), 'error'); bp_core_redirect(buddydrive_get_root_url()); } $buddydrive_file_path = $buddydrive_file->path; $buddydrive_file_name = $buddydrive_file->file; $buddydrive_file_mime = $buddydrive_file->mime_type; // if the file belongs to a folder, we need to get the folder's privacy settings if (!empty($buddydrive_file->post_parent)) { $parent = $buddydrive_file->post_parent; $buddydrive_file = buddydrive_get_buddyfile($parent, buddydrive_get_folder_post_type()); } $can_donwload = false; if (!empty($buddydrive_file->check_for)) { switch ($buddydrive_file->check_for) { case 'private': if ($buddydrive_file->user_id == bp_loggedin_user_id() || is_super_admin()) { $can_donwload = true; } break; case 'password': if ($buddydrive_file->user_id == bp_loggedin_user_id() || is_super_admin()) { $can_donwload = true; } elseif (empty($_POST['buddyfile-form'])) { bp_core_add_message(__('This file is password protected', 'buddydrive'), 'error'); add_action('buddydrive_directory_content', 'buddydrive_file_password_form'); $can_donwload = false; } else { //check admin referer if ($buddydrive_file->password == $_POST['buddyfile-form']['password']) { $can_donwload = true; } else { $redirect = buddydrive_get_user_buddydrive_url($buddydrive_file->user_id); bp_core_add_message(__('Wrong password', 'buddydrive'), 'error'); bp_core_redirect($redirect); $can_donwload = false; } } break; case 'public': $can_donwload = true; break; case 'friends': if ($buddydrive_file->user_id == bp_loggedin_user_id() || is_super_admin()) { $can_donwload = true; } elseif (bp_is_active('friends') && friends_check_friendship($buddydrive_file->user_id, bp_loggedin_user_id())) { $can_donwload = true; } else { $redirect = buddydrive_get_user_buddydrive_url($buddydrive_file->user_id); bp_core_add_message(__('You must be a friend of this member to download the file', 'buddydrive'), 'error'); bp_core_redirect($redirect); $can_donwload = false; } break; case 'groups': if ($buddydrive_file->user_id == bp_loggedin_user_id() || is_super_admin()) { $can_donwload = true; } elseif (!bp_is_active('groups')) { bp_core_add_message(__('Group component is deactivated, please contact the administrator.', 'buddydrive'), 'error'); bp_core_redirect(buddydrive_get_root_url()); $can_donwload = false; } elseif (groups_is_user_member(bp_loggedin_user_id(), intval($buddydrive_file->group))) { $can_donwload = true; } else { $group = groups_get_group(array('group_id' => $buddydrive_file->group)); if ('hidden' == $group->status) { $redirect = wp_get_referer(); } else { $redirect = bp_get_group_permalink($group); } bp_core_add_message(__('You must be member of the group to download the file', 'buddydrive'), 'error'); bp_core_redirect($redirect); $can_donwload = false; } break; default: /** * Filter here for custom privacy options * * @since 1.3.3 * * @param bool $can_download True if the file can be downloaded, false otherwise. * @param object $buddydrive_file The BuddyDrive file object. */ $can_donwload = apply_filters('buddydrive_file_downloader_can_download', $can_download, $buddydrive_file); break; } } else { if ($buddydrive_file->user_id == bp_loggedin_user_id() || is_super_admin()) { $can_donwload = true; } } // we have a file! let's force download. if (file_exists($buddydrive_file_path) && !empty($can_donwload)) { do_action('buddydrive_file_downloaded', $buddydrive_file); status_header(200); header('Cache-Control: cache, must-revalidate'); header('Pragma: public'); header('Content-Description: File Transfer'); header('Content-Length: ' . filesize($buddydrive_file_path)); header('Content-Disposition: attachment; filename=' . $buddydrive_file_name); header('Content-Type: ' . $buddydrive_file_mime); readfile($buddydrive_file_path); die; } } else { if (!bp_displayed_user_id() && bp_is_current_component('buddydrive') && 'folder' == bp_current_action()) { $buddyfolder_name = bp_action_variable(0); $buddyfolder = buddydrive_get_buddyfile($buddyfolder_name, buddydrive_get_folder_post_type()); if (empty($buddyfolder)) { bp_core_add_message(__('OOps, we could not find your folder.', 'buddydrive'), 'error'); bp_core_redirect(buddydrive_get_root_url()); } // in case of the folder, we open it on the user's BuddyDrive or the group one $buddydrive_root_link = $buddyfolder->check_for == 'groups' ? buddydrive_get_group_buddydrive_url($buddyfolder->group) : buddydrive_get_user_buddydrive_url($buddyfolder->user_id); $link = $buddydrive_root_link . '?folder-' . $buddyfolder->ID; bp_core_redirect($link); } } }
function bp_dtheme_ajax_invite_user() { global $bp; check_ajax_referer('groups_invite_uninvite_user'); if (!$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id']) { return false; } if (!bp_groups_user_can_send_invites($_POST['group_id']) || !friends_check_friendship($bp->loggedin_user->id, $_POST['friend_id'])) { return false; } if ('invite' == $_POST['friend_action']) { if (!groups_invite_user(array('user_id' => $_POST['friend_id'], 'group_id' => $_POST['group_id']))) { return false; } $user = new BP_Core_User($_POST['friend_id']); echo '<li id="uid-' . $user->id . '">'; echo $user->avatar_thumb; echo '<h4>' . $user->user_link . '</h4>'; echo '<span class="activity">' . esc_attr($user->last_active) . '</span>'; echo '<div class="action"> <a class="button remove" href="' . wp_nonce_url($bp->loggedin_user->domain . bp_get_groups_slug() . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user') . '" id="uid-' . esc_attr($user->id) . '">' . __('Remove Invite', 'buddypress') . '</a> </div>'; echo '</li>'; } else { if ('uninvite' == $_POST['friend_action']) { return (bool) groups_uninvite_user($_POST['friend_id'], $_POST['group_id']); } else { return false; } } }
/** * bp_get_nav() * TEMPLATE TAG * * Uses the $bp->bp_nav global to render out the navigation within a BuddyPress install. * Each component adds to this navigation array within its own [component_name]_setup_nav() function. * * This navigation array is the top level navigation, so it contains items such as: * [Blog, Profile, Messages, Groups, Friends] ... * * The function will also analyze the current component the user is in, to determine whether * or not to highlight a particular nav item. * * @package BuddyPress Core * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() */ function bp_get_loggedin_user_nav() { global $bp, $current_blog; /* Loop through each navigation item */ foreach( (array) $bp->bp_nav as $nav_item ) { /* If the current component matches the nav item id, then add a highlight CSS class. */ if ( !bp_is_directory() && $bp->active_components[$bp->current_component] == $nav_item['css_id'] ) $selected = ' class="current selected"'; else $selected = ''; /* If we are viewing another person (current_userid does not equal loggedin_user->id) then check to see if the two users are friends. if they are, add a highlight CSS class to the friends nav item if it exists. */ if ( !bp_is_my_profile() && $bp->displayed_user->id ) { $selected = ''; if ( function_exists('friends_install') ) { if ( $nav_item['css_id'] == $bp->friends->id ) { if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) ) $selected = ' class="current selected"'; } } } /* echo out the final list item */ echo apply_filters( 'bp_get_loggedin_user_nav_' . $nav_item['css_id'], '<li id="li-nav-' . $nav_item['css_id'] . '" ' . $selected . '><a id="my-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>', &$nav_item ); } /* Always add a log out list item to the end of the navigation */ if ( function_exists( 'wp_logout_url' ) ) { $logout_link = '<li><a id="wp-logout" href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>'; } else { $logout_link = '<li><a id="wp-logout" href="' . site_url() . '/wp-login.php?action=logout&redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>'; } echo apply_filters( 'bp_logout_nav_link', $logout_link ); }