/** * Follow button */ function get_follow_button() { if (bp_follow_is_following(array('leader_id' => get_the_author_meta('ID'), 'follower_id' => bp_loggedin_user_id()))) { $link_text = __('Unfollow', 'artgorae'); } else { $link_text = __('Follow', 'artgorae'); } $args = array('leader_id' => get_the_author_meta('ID'), 'follower_id' => bp_loggedin_user_id(), 'link_text' => $link_text, 'link_class' => 'button alt', 'wrapper' => ''); echo bp_follow_get_add_follow_button($args); }
/** * Filter the activity loop. * * Specifically, when on the activity directory and clicking on the "Followed * Sites" tab. * * @param str $qs The querystring for the BP loop * @param str $object The current object for the querystring * @return str Modified querystring */ function bp_follow_blogs_add_activity_scope_filter($qs, $object) { // not on the blogs object? stop now! if ($object != 'activity') { return $qs; } // parse querystring into an array $r = wp_parse_args($qs); if (bp_is_current_action(constant('BP_FOLLOW_BLOGS_USER_ACTIVITY_SLUG'))) { $r['scope'] = 'followblogs'; } if (!isset($r['scope'])) { return $qs; } if ('followblogs' !== $r['scope']) { return $qs; } // get blog IDs that the user is following $following_ids = bp_get_following_ids(array('user_id' => bp_displayed_user_id() ? bp_displayed_user_id() : bp_loggedin_user_id(), 'follow_type' => 'blogs')); // if $following_ids is empty, pass a negative number so no blogs can be found $following_ids = empty($following_ids) ? -1 : $following_ids; $args = array('user_id' => 0, 'object' => 'blogs', 'primary_id' => $following_ids); // make sure we add a separator if we have an existing querystring if (!empty($qs)) { $qs .= '&'; } // add our follow parameters to the end of the querystring $qs .= build_query($args); // support BP Groupblog // We need to filter the WHERE SQL conditions to do this if (function_exists('bp_groupblog_init')) { add_filter('bp_activity_get_where_conditions', 'bp_follow_blogs_groupblog_activity_where_conditions', 10, 2); } return $qs; }
/** * Set the directory when uploading a file. * * @since 2.4.0 * * @param array $upload_dir The original Uploads dir. * @return array $value Upload data (path, url, basedir...). */ public function upload_dir_filter($upload_dir = array()) { // Default values are for profiles. $object_id = bp_displayed_user_id(); if (empty($object_id)) { $object_id = bp_loggedin_user_id(); } $object_directory = 'members'; // We're in a group, edit default values. if (bp_is_group() || bp_is_group_create()) { $object_id = bp_get_current_group_id(); $object_directory = 'groups'; } // Set the subdir. $subdir = '/' . $object_directory . '/' . $object_id . '/cover-image'; /** * Filters the cover image upload directory. * * @since 2.4.0 * * @param array $value Array containing the path, URL, and other helpful settings. * @param array $upload_dir The original Uploads dir. */ return apply_filters('bp_attachments_cover_image_upload_dir', array('path' => $this->upload_path . $subdir, 'url' => $this->url . $subdir, 'subdir' => $subdir, 'basedir' => $this->upload_path, 'baseurl' => $this->url, 'error' => false), $upload_dir); }
/** * Filter the activity loop when we're on a "Following" page * * This is done: * - On the activity directory and clicking on the "Following" tab * - On a user's "Activity > Following" page * * @since 1.0.0 * * @param string|array Current activity querystring * @param string $object The current object or component * @return array */ function bp_follow_add_activity_scope_filter($qs, $object) { global $bp; // not on the activity object? stop now! if ($object != 'activity') { return $qs; } $set = false; // activity directory // can't use bp_is_activity_directory() yet since that's a BP 2.0 function if (!bp_displayed_user_id() && bp_is_activity_component() && !bp_current_action()) { // check if activity scope is following before manipulating if (isset($_COOKIE['bp-activity-scope']) && 'following' === $_COOKIE['bp-activity-scope']) { $set = true; } // user's activity following page } elseif (bp_is_user_activity() && bp_is_current_action('following')) { $set = true; } // not on a user page? stop now! if (!$set) { return $qs; } // set internal marker noting that our activity scope is applied $bp->follow->activity_scope_set = 1; $qs = wp_parse_args($qs); $following_ids = bp_get_following_ids(array('user_id' => bp_displayed_user_id() ? bp_displayed_user_id() : bp_loggedin_user_id())); // if $following_ids is empty, pass a negative number so no activity can be found $following_ids = empty($following_ids) ? -1 : $following_ids; $qs['user_id'] = $following_ids; return apply_filters('bp_follow_add_activity_scope_filter', $qs, false); }
/** * Can the current user post to group blog * @global type $bp * @return type */ function bcg_current_user_can_post() { $user_id = bp_loggedin_user_id(); $group_id = bp_get_current_group_id(); $can_post = is_user_logged_in() && (groups_is_user_admin($user_id, $group_id) || groups_is_user_mod($user_id, $group_id)); return apply_filters('bcg_current_user_can_post', $can_post, $group_id, $user_id); }
/** * 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; }
function bp_media_show_upload_form_multiple() { global $bp, $bp_media_default_excerpts; ?> <div id="bp-media-album-prompt" title="Select Album"><select id="bp-media-selected-album"><?php $albums = new WP_Query(array('post_type' => 'bp_media_album', 'posts_per_page' => -1, 'author' => get_current_user_id())); if (isset($albums->posts) && is_array($albums->posts) && count($albums->posts) > 0) { foreach ($albums->posts as $album) { if ($album->post_title == 'Wall Posts') { echo '<option value="' . $album->ID . '" selected="selected">' . $album->post_title . '</option>'; } else { echo '<option value="' . $album->ID . '">' . $album->post_title . '</option>'; } } } else { $album = new BP_Media_Album(); $album->add_album('Wall Posts', bp_loggedin_user_id()); echo '<option value="' . $album->get_id() . '" selected="selected">' . $album->get_title() . '</option>'; } ?> </select></div> <div id="bp-media-album-new" title="Create New Album"><label for="bp_media_album_name">Album Name</label><input id="bp_media_album_name" type="text" name="bp_media_album_name" /></div> <div id="bp-media-upload-ui" class="hide-if-no-js drag-drop"> <div id="drag-drop-area"> <div class="drag-drop-inside"> <p class="drag-drop-info">Drop files here</p> <p>or</p> <p class="drag-drop-buttons"><input id="bp-media-upload-browse-button" type="button" value="Select Files" class="button" /></p> </div> </div> </div> <div id="bp-media-uploaded-files"></div> <?php }
/** * Make sure that action filters ('activity_update', etc) work when * limiting query to user favorites * * @ticket BP4872 * @group scope */ public function test_bp_has_activities_favorites_action_filter() { $user_id = $this->factory->user->create(array('role' => 'subscriber')); $now = time(); $a1 = $this->factory->activity->create(array('type' => 'activity_update', 'recorded_time' => date('Y-m-d H:i:s', $now))); $a2 = $this->factory->activity->create(array('type' => 'joined_group', 'recorded_time' => date('Y-m-d H:i:s', $now - 100))); $current_user = bp_loggedin_user_id(); $this->set_current_user($user_id); bp_activity_add_user_favorite($a1, $user_id); bp_activity_add_user_favorite($a2, $user_id); $this->set_current_user($current_user); // groan. It sucks that you have to invoke the global global $activities_template; // Case 1: no action filter bp_has_activities(array('user_id' => $user_id, 'scope' => 'favorites')); // The formatting of $activities_template->activities is messed // up, so we're just going to look at the IDs. This should be // fixed in BP at some point $ids = wp_list_pluck($activities_template->activities, 'id'); $this->assertEquals(array($a1, $a2), $ids); $activities_template = null; // Case 2: action filter bp_has_activities(array('user_id' => $user_id, 'scope' => 'favorites', 'action' => 'activity_update')); $ids = wp_list_pluck($activities_template->activities, 'id'); $this->assertEquals(array($a1), $ids); $activities_template = null; }
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(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(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()); } do_action('friends_screen_requests'); if (isset($_GET['new'])) { bp_core_delete_notifications_by_type(bp_loggedin_user_id(), 'friends', 'friendship_request'); } bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home')); }
/** * BP_Groups_Invite_Template constructor. * * @since 1.5.0 * * @param array $args */ public function __construct($args = array()) { // Backward compatibility with old method of passing arguments. if (!is_array($args) || func_num_args() > 1) { _deprecated_argument(__METHOD__, '2.0.0', sprintf(__('Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress'), __METHOD__, __FILE__)); $old_args_keys = array(0 => 'user_id', 1 => 'group_id'); $func_args = func_get_args(); $args = bp_core_parse_args_array($old_args_keys, $func_args); } $r = wp_parse_args($args, array('page' => 1, 'per_page' => 10, 'page_arg' => 'invitepage', 'user_id' => bp_loggedin_user_id(), 'group_id' => bp_get_current_group_id())); $this->pag_arg = sanitize_key($r['page_arg']); $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $r['page']); $this->pag_num = bp_sanitize_pagination_arg('num', $r['per_page']); $iquery = new BP_Group_Member_Query(array('group_id' => $r['group_id'], 'type' => 'first_joined', 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'is_confirmed' => false, 'inviter_id' => $r['user_id'])); $this->invite_data = $iquery->results; $this->total_invite_count = $iquery->total_users; $this->invites = array_values(wp_list_pluck($this->invite_data, 'ID')); $this->invite_count = count($this->invites); // If per_page is set to 0 (show all results), don't generate // pag_links. if (!empty($this->pag_num)) { $this->pag_links = paginate_links(array('base' => add_query_arg($this->pag_arg, '%#%'), 'format' => '', 'total' => ceil($this->total_invite_count / $this->pag_num), 'current' => $this->pag_page, 'prev_text' => '←', 'next_text' => '→', 'mid_size' => 1, 'add_args' => array())); } else { $this->pag_links = ''; } }
/** * Delete a specific notification by its ID * * @since BuddyPress (1.0) * @param int $id * @return boolean True on success, false on fail */ function bp_core_delete_notification($id) { if (!bp_core_check_notification_access(bp_loggedin_user_id(), $id)) { return false; } return BP_Core_Notification::delete($id); }
function dln_get_notifications_objects() { if (!is_user_logged_in()) { return false; } $notifications = BP_Notifications_Notification::get(array('user_id' => bp_loggedin_user_id(), 'is_new' => '1', 'component_name' => bp_notifications_get_registered_components())); if (!$notifications) { return; } $count_m = $count_f = $count_a = 0; $arr_m = $arr_f = $arr_a = array(); foreach ($notifications as $i => $nof) { switch ($nof->component_name) { case 'messages': $count_m++; $arr_m[] = $nof; break; case 'friends': $count_f++; $arr_f[] = $nof; break; } } $result = array(); $result['messages'] = array('nof_count' => $count_m, 'nof_arr' => $arr_m); $result['friends'] = array('nof_type' => 'friends', 'nof_count' => $count_f, 'nof_arr' => $arr_f); return $result; }
function friends_clear_friend_notifications() { global $bp; if (isset($_GET['new'])) { bp_core_delete_notifications_by_type(bp_loggedin_user_id(), $bp->friends->id, 'friendship_accepted'); } }
/** * 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')); }
/** * Load the Forums directory. */ function bp_forums_directory_forums_setup() { // Get BuddyPress once $bp = buddypress(); if (bp_is_forums_component() && (!bp_current_action() || 'tag' == bp_current_action() && bp_action_variables()) && !bp_current_item()) { if (!bp_forums_has_directory()) { return false; } if (!bp_forums_is_installed_correctly()) { bp_core_add_message(__('The forums component has not been set up yet.', 'buddypress'), 'error'); bp_core_redirect(bp_get_root_domain()); } bp_update_is_directory(true, 'forums'); do_action('bbpress_init'); // Check to see if the user has posted a new topic from the forums page. if (isset($_POST['submit_topic']) && bp_is_active('forums')) { check_admin_referer('bp_forums_new_topic'); $bp->groups->current_group = groups_get_group(array('group_id' => $_POST['topic_group_id'])); if (!empty($bp->groups->current_group->id)) { // Auto join this user if they are not yet a member of this group if (!bp_current_user_can('bp_moderate') && 'public' == $bp->groups->current_group->status && !groups_is_user_member(bp_loggedin_user_id(), $bp->groups->current_group->id)) { groups_join_group($bp->groups->current_group->id); } $error_message = ''; $forum_id = groups_get_groupmeta($bp->groups->current_group->id, 'forum_id'); if (!empty($forum_id)) { if (empty($_POST['topic_title'])) { $error_message = __('Please provide a title for your forum topic.', 'buddypress'); } else { if (empty($_POST['topic_text'])) { $error_message = __('Forum posts cannot be empty. Please enter some text.', 'buddypress'); } } if ($error_message) { bp_core_add_message($error_message, 'error'); $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum'; } else { if (!($topic = groups_new_group_forum_topic($_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id))) { bp_core_add_message(__('There was an error when creating the topic', 'buddypress'), 'error'); $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum'; } else { bp_core_add_message(__('The topic was created successfully', 'buddypress')); $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic->topic_slug . '/'; } } bp_core_redirect($redirect); } else { bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error'); bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink())); } } else { bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error'); bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink())); } } do_action('bp_forums_directory_forums_setup'); bp_core_load_template(apply_filters('bp_forums_template_directory_forums_setup', 'forums/index')); } }
/** * Record an activity item related to the Friends component. * * A wrapper for {@link bp_activity_add()} that provides some Friends-specific * defaults. * * @see bp_activity_add() for more detailed description of parameters and * return values. * * @param array $args { * An array of arguments for the new activity item. Accepts all parameters * of {@link bp_activity_add()}. The one difference is the following * argument, which has a different default here: * @type string $component Default: the id of your Friends component * (usually 'friends'). * } * @return bool See {@link bp_activity_add()}. */ function friends_record_activity($args = '') { if (!bp_is_active('activity')) { return false; } $r = wp_parse_args($args, array('user_id' => bp_loggedin_user_id(), 'action' => '', 'content' => '', 'primary_link' => '', 'component' => buddypress()->friends->id, 'type' => false, 'item_id' => false, 'secondary_item_id' => false, 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => false)); return bp_activity_add($r); }
public function upload_dir_filter() { $upload_dir_data = parent::upload_dir_filter(); if (!is_user_logged_in()) { return $upload_dir_data; } return array('path' => $this->upload_path . '/' . bp_loggedin_user_id(), 'url' => $this->url . '/' . bp_loggedin_user_id(), 'subdir' => '/' . bp_loggedin_user_id(), 'basedir' => $this->upload_path . '/' . bp_loggedin_user_id(), 'baseurl' => $this->url . '/' . bp_loggedin_user_id(), 'error' => false); }
public function setUp() { parent::setUp(); $this->current_user = bp_loggedin_user_id(); $this->set_current_user(0); if (isset($GLOBALS['groups_template'])) { $this->groups_template = $GLOBALS['groups_template']; } }
function dln_get_avatar_link() { if (!bp_loggedin_user_id()) { return ''; } $user_id = bp_loggedin_user_id(); $link = bp_core_fetch_avatar(array('item_id' => $user_id, 'width' => 40, 'height' => 40, 'class' => 'img-circle', 'alt' => bp_core_get_user_displayname($user_id))); return $link; }
function userpro_bp_loggedin_user_domain() { global $userpro, $bp; if (!is_admin()) { return $userpro->permalink(bp_loggedin_user_id()); } else { return $bp->loggedin_user->domain; } }
function bp_links_dtheme_activity_type_tabs_setup() { global $bp; if (!bp_links_is_default_theme()) { return false; } if (is_user_logged_in() && bp_links_total_links_for_user(bp_loggedin_user_id())) { echo sprintf('<li id="activity-links"><a href="%s" title="%s">%s</a></li>', bp_loggedin_user_domain() . BP_ACTIVITY_SLUG . '/' . bp_links_slug() . '/', __('The activity of links I created.', 'buddypress-links'), __('My Links', 'buddypress-links') . sprintf(' <span>%s</span>', bp_links_total_links_for_user(bp_loggedin_user_id()))); } }
/** * Clear message cache after a message thread is deleted. * * @since 2.0.0 * * @param int|array $thread_ids If single thread, the thread ID. * Otherwise, an array of thread IDs. */ function bp_messages_clear_cache_on_message_delete($thread_ids) { // Delete thread and thread recipient cache. foreach ((array) $thread_ids as $thread_id) { wp_cache_delete($thread_id, 'bp_messages_threads'); wp_cache_delete("thread_recipients_{$thread_id}", 'bp_messages'); } // Delete unread count for logged-in user. wp_cache_delete(bp_loggedin_user_id(), 'bp_messages_unread_count'); }
/** * Get all friends * * @param WP_REST_Request $request * @return array|WP_Error */ public function get_items($request) { $get_function = 'friends_get_' . $request['sort']; $friends = $get_function(bp_loggedin_user_id()); if (!$friends) { return new WP_Error('bp_json_friends', __('No Friends Found.', BP_API_PLUGIN_SLUG), array('status' => 200)); } $data = apply_filters('bp_json_prepare_friends', $friends); return new WP_REST_Response($data, 200); }
/** * Build script datas for the Uploader UI */ public function script_data() { // Get default script data $script_data = parent::script_data(); $script_data['bp_params'] = array('item_id' => bp_loggedin_user_id()); // Include our specific css $script_data['extra_css'] = array('fe-attachments-style'); // Include our specific js $script_data['extra_js'] = array('fe-attachments-script'); return apply_filters('front_end_attachment_script_data', $script_data); }
/** * * @return type * @since 0.5 * @version 1.2.2 * v2, 10/5/2013 */ function cac_catch_group_doc_request() { $error = false; if (empty($_GET['get_group_doc'])) { return; } $doc_id = $_GET['get_group_doc']; // Check to see whether the current user has access to the doc in question $file_deets = explode('/', $doc_id); $group_id = $file_deets[0]; $group = new BP_Groups_Group($group_id); $doc_name = $file_deets[1]; if (empty($group->id)) { $error = array('message' => __('That group does not exist.', 'bp-group-documents'), 'redirect' => bp_get_root_domain()); } else { if ($group->status != 'public') { // If the group is not public, if (!is_super_admin()) { //then the user must be logged in and // a member of the group to download the document if (!is_user_logged_in() || !groups_is_user_member(bp_loggedin_user_id(), $group_id)) { $error = array('message' => sprintf(__('You must be a logged-in member of the group %s to access this document. If you are a member of the group, please log into the site and try again.', 'bp-group-documents'), $group->name), 'redirect' => bp_get_group_permalink($group)); } } } // If we have gotten this far without an error, then the download can go through if (!$error) { $document = new BP_Group_Documents(); $document->populate_by_file($doc_name); $doc_path = $document->get_path(); clearstatcache(); if (file_exists($doc_path)) { $mime_type = mime_content_type($doc_path); $doc_size = filesize($doc_path); header("Cache-Control: public, must-revalidate, post-check=0, pre-check=0"); header("Pragma: hack"); header("Content-Type: {$mime_type}; name='" . $file_deets[1] . "'"); header("Content-Length: " . $doc_size); header('Content-Disposition: inline; filename="' . $file_deets[1] . '"'); header("Content-Transfer-Encoding: binary"); ob_clean(); flush(); readfile($doc_path); die; } else { // File does not exist $error = array('message' => _e('The file could not be found.', 'bp-group-documents'), 'redirect' => bp_get_group_permalink($group) . 'documents'); } } } // If we have gotten this far, there was an error. Add a message and redirect bp_core_add_message($error['message'], 'error'); bp_core_redirect($error['redirect']); }
/** * Post a gallery or media Main comment on single page * * @return type */ public function post_comment() { // Bail if not a POST action if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) { return; } // Check the nonce check_admin_referer('post_update', '_wpnonce_post_update'); if (!is_user_logged_in()) { exit('-1'); } $mpp_type = $_POST['mpp-type']; $mpp_id = $_POST['mpp-id']; if (empty($_POST['content'])) { exit('-1<div id="message" class="error"><p>' . __('Please enter some content to post.', 'mediapress') . '</p></div>'); } $activity_id = 0; if (empty($_POST['object']) && bp_is_active('activity')) { //we are preventing this comment to be set as the user's lastes_update $user_id = bp_loggedin_user_id(); $old_latest_update = bp_get_user_meta($user_id, 'bp_latest_update', true); $activity_id = bp_activity_post_update(array('content' => $_POST['content'])); //restore if (!empty($old_latest_update)) { bp_update_user_meta($user_id, 'bp_latest_update', $old_latest_update); } } elseif ($_POST['object'] == 'groups') { if (!empty($_POST['item_id']) && bp_is_active('groups')) { $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id'])); } } else { $activity_id = apply_filters('bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content']); } if (empty($activity_id)) { exit('-1<div id="message" class="error"><p>' . __('There was a problem posting your update, please try again.', 'mediapress') . '</p></div>'); } //if we have got activity id, let us add a meta key if ($mpp_type == 'gallery') { mpp_activity_update_gallery_id($activity_id, $mpp_id); } elseif ($mpp_type == 'media') { mpp_activity_update_media_id($activity_id, $mpp_id); } $activity = new BP_Activity_Activity($activity_id); // $activity->component = buddypress()->mediapress->id; $activity->type = 'mpp_media_upload'; $activity->save(); if (bp_has_activities('include=' . $activity_id)) { while (bp_activities()) { bp_the_activity(); mpp_locate_template(array('activity/entry.php'), true); } } exit; }
function ajax_navigation_func() { $notifyAmount = bp_notifications_get_unread_notification_count(bp_loggedin_user_id()); $messageAmount = messages_get_unread_count(); $friendRequests = bp_friend_get_total_requests_count(); $groups = groups_get_invites_for_user(bp_loggedin_user_id()); $groupInvites = $groups['total']; $navigationData = array('notifyAmount' => $notifyAmount, 'messageAmount' => $messageAmount, 'friendRequests' => $friendRequests, 'groupInvites' => $groupInvites); echo json_encode($navigationData); die; }
function custom_get_user_posts_count($status) { $args = array(); $args['post_status'] = $status; $args['author'] = bp_loggedin_user_id(); $args['fields'] = 'ids'; $args['posts_per_page'] = "-1"; $args['post_type'] = 'post'; $ps = get_posts($args); return count($ps); }
public function test_get_hidden_field_types_for_user_admin() { $duser = $this->factory->user->create(); $cuser = $this->factory->user->create(); $this->grant_bp_moderate($cuser); $old_current_user = bp_loggedin_user_id(); $this->set_current_user($cuser); $this->assertEquals(array(), bp_xprofile_get_hidden_field_types_for_user($duser, bp_loggedin_user_id())); $this->revoke_bp_moderate($cuser); $this->set_current_user($old_current_user); }
function friends_record_activity($args = '') { global $bp; if (!bp_is_active('activity')) { return false; } $defaults = array('user_id' => bp_loggedin_user_id(), 'action' => '', 'content' => '', 'primary_link' => '', 'component' => $bp->friends->id, 'type' => false, 'item_id' => false, 'secondary_item_id' => false, 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => false); $r = wp_parse_args($args, $defaults); extract($r, EXTR_SKIP); return bp_activity_add(array('user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide)); }