groups_post_update (|字符串数组args美元='')
发布与组关联的活动状态更新。
描述
参数
- args美元
-
(数组|字符串)(可选)数组的参数。
- “内容”
(int)要编辑的活动的ID。 - “内容”
(字符串)更新内容。 - “user_id”
(int)可选的。发布更新的用户ID。默认值:登录用户的ID。 - “group_id”
(int)可选的。要与更新关联的组的ID。Default:当前组ID。
默认值:“
- “内容”
返回
(WP_Error | bool | int)成功时返回新活动项的ID,失败时返回false。
源
文件:bp-groups / bp-groups-functions.php
Function group_post_update ($args = ") {if (!Bp_is_active ('activity')){返回false;} $bp = buddypress();$r = bp_parse_args($args, array('content' => false, 'user_id' => bp_loggedin_user_id(), 'group_id' => 0, 'error_type' => 'bool'), 'groups_post_update');($r, EXTR_SKIP);If ($bp->groups->current_group->id)) $group_id = $bp->groups->current_group->id; $bp->groups->current_group->id;If (//empty($content) || !strlen(trim($content)) || empty($user_id) || empty($group_id))返回false;$bp->groups->current_group = group_get_group ($group_id); / /用户组//在发布之前确定用户是组的成员。If (!bp_current_user_can('bp_moderate') && ! group_is_user_member ($user_id, $group_id) && ! groups_is_user_allowed_posting( $user_id, $group_id ) ) return false; // Record this in activity feeds. $activity_action = sprintf( __( '%1$s posted an update in the group %2$s', 'buddyboss'), bp_core_get_userlink( $user_id ), '' . esc_attr( $bp->groups->current_group->name ) . '' ); $activity_content = $content; /** * Filters the action for the new group activity update. * * @since BuddyPress 1.2.0 * * @param string $activity_action The new group activity update. */ $action = apply_filters( 'groups_activity_new_update_action', $activity_action ); /** * Filters the content for the new group activity update. * * @since BuddyPress 1.2.0 * * @param string $activity_content The content of the update. */ $content_filtered = apply_filters( 'groups_activity_new_update_content', $activity_content ); $activity_id = groups_record_activity( array( 'user_id' => $user_id, 'action' => $action, 'content' => $content_filtered, 'type' => 'activity_update', 'item_id' => $group_id, 'error_type' => $error_type ) ); groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() ); /** * Fires after posting of an Activity status update affiliated with a group. * * @since BuddyPress 1.2.0 * * @param string $content The content of the update. * @param int $user_id ID of the user posting the update. * @param int $group_id ID of the group being posted to. * @param bool $activity_id Whether or not the activity recording succeeded. */ do_action( 'bp_groups_posted_update', $content, $user_id, $group_id, $activity_id ); return $activity_id; }
更新日志
版本 | 描述 |
---|---|
BuddyPress 2.6.0添加了'error_type'参数到$args。 | BuddyPress 2.6.0添加了'error_type'参数到$args。 |
BuddyPress 1.2.0 | 介绍了。 |