Changeset 12395 for trunk/src/bp-groups/bp-groups-functions.php
- Timestamp:
- 05/11/2019 01:33:14 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-functions.php
r12393 r12395 1267 1267 } 1268 1268 1269 /** Group Activity Posting ****************************************************/1270 1271 /**1272 * Post an Activity status update affiliated with a group.1273 *1274 * @since 1.2.01275 * @since 2.6.0 Added 'error_type' parameter to $args.1276 *1277 * @param array|string $args {1278 * Array of arguments.1279 * @type string $content The content of the update.1280 * @type int $user_id Optional. ID of the user posting the update. Default:1281 * ID of the logged-in user.1282 * @type int $group_id Optional. ID of the group to be affiliated with the1283 * update. Default: ID of the current group.1284 * }1285 * @return WP_Error|bool|int Returns the ID of the new activity item on success, or false on failure.1286 */1287 function groups_post_update( $args = '' ) {1288 if ( ! bp_is_active( 'activity' ) ) {1289 return false;1290 }1291 1292 $bp = buddypress();1293 1294 $r = bp_parse_args( $args, array(1295 'content' => false,1296 'user_id' => bp_loggedin_user_id(),1297 'group_id' => 0,1298 'error_type' => 'bool'1299 ), 'groups_post_update' );1300 extract( $r, EXTR_SKIP );1301 1302 if ( empty( $group_id ) && !empty( $bp->groups->current_group->id ) )1303 $group_id = $bp->groups->current_group->id;1304 1305 if ( empty( $content ) || !strlen( trim( $content ) ) || empty( $user_id ) || empty( $group_id ) )1306 return false;1307 1308 $bp->groups->current_group = groups_get_group( $group_id );1309 1310 // Be sure the user is a member of the group before posting.1311 if ( !bp_current_user_can( 'bp_moderate' ) && !groups_is_user_member( $user_id, $group_id ) )1312 return false;1313 1314 // Record this in activity streams.1315 $activity_action = sprintf( esc_html__( '%1$s posted an update in the group %2$s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . esc_url( bp_get_group_permalink( $bp->groups->current_group ) ) . '">' . esc_html( $bp->groups->current_group->name ) . '</a>' );1316 $activity_content = $content;1317 1318 /**1319 * Filters the action for the new group activity update.1320 *1321 * @since 1.2.01322 *1323 * @param string $activity_action The new group activity update.1324 */1325 $action = apply_filters( 'groups_activity_new_update_action', $activity_action );1326 1327 /**1328 * Filters the content for the new group activity update.1329 *1330 * @since 1.2.01331 *1332 * @param string $activity_content The content of the update.1333 */1334 $content_filtered = apply_filters( 'groups_activity_new_update_content', $activity_content );1335 1336 $activity_id = groups_record_activity( array(1337 'user_id' => $user_id,1338 'action' => $action,1339 'content' => $content_filtered,1340 'type' => 'activity_update',1341 'item_id' => $group_id,1342 'error_type' => $error_type1343 ) );1344 1345 groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );1346 1347 /**1348 * Fires after posting of an Activity status update affiliated with a group.1349 *1350 * @since 1.2.01351 *1352 * @param string $content The content of the update.1353 * @param int $user_id ID of the user posting the update.1354 * @param int $group_id ID of the group being posted to.1355 * @param bool $activity_id Whether or not the activity recording succeeded.1356 */1357 do_action( 'bp_groups_posted_update', $content, $user_id, $group_id, $activity_id );1358 1359 return $activity_id;1360 }1361 1362 1269 /** Group Invitations *********************************************************/ 1363 1270
Note: See TracChangeset
for help on using the changeset viewer.