Changeset 13367
- Timestamp:
- 11/13/2022 12:50:54 PM (2 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-functions.php
r13337 r13367 2114 2114 'user_id' => bp_loggedin_user_id(), 2115 2115 'error_type' => 'bool', 2116 ) 2116 ), 2117 'activity_post_update' 2117 2118 ); 2118 2119 -
trunk/src/bp-groups/bp-groups-activity.php
r13312 r13367 579 579 } 580 580 581 $content = $r['content']; 582 $user_id = (int) $r['user_id']; 583 if ( ! $content || ! strlen( trim( $content ) ) || ! $user_id || ! $group_id ) { 584 return false; 585 } 586 587 $bp->groups->current_group = groups_get_group( $group_id ); 588 589 // Be sure the user is a member of the group before posting. 590 if ( ! bp_current_user_can( 'bp_moderate' ) && ! groups_is_user_member( $user_id, $group_id ) ) { 581 $content = $r['content']; 582 $user_id = (int) $r['user_id']; 583 $is_user_active = bp_is_user_active( $user_id ); 584 $is_group_allowed = $group_id && ( bp_current_user_can( 'bp_moderate' ) || groups_is_user_member( $user_id, $group_id ) ); 585 586 if ( ! $content || ! strlen( trim( $content ) ) || ! $is_user_active || ! $is_group_allowed ) { 587 if ( 'wp_error' === $r['error_type'] ) { 588 $error_code = 'bp_activity_missing_content'; 589 $error_code_message = __( 'Please enter some content to post.', 'buddypress' ); 590 591 if ( ! $is_user_active ) { 592 $error_code = 'bp_activity_inactive_user'; 593 $error_code_message = __( 'User account has not yet been activated.', 'buddypress' ); 594 } elseif ( ! $is_group_allowed ) { 595 $error_code = 'bp_activity_unallowed_group'; 596 $error_code_message = __( 'You need to be a member of this group to share updates with their members.', 'buddypress' ); 597 } 598 599 return new WP_Error( $error_code, $error_code_message ); 600 } 601 591 602 return false; 592 603 } -
trunk/src/bp-templates/bp-nouveau/includes/activity/ajax.php
r13222 r13367 507 507 } 508 508 509 if ( empty( $_POST['content'] ) ) {510 wp_send_json_error(511 array(512 'message' => __( 'Please enter some content to post.', 'buddypress' ),513 )514 );515 }516 517 509 $activity_id = 0; 518 510 $item_id = 0; … … 537 529 538 530 if ( 'user' === $object && bp_is_active( 'activity' ) ) { 539 $activity_id = bp_activity_post_update( array( 'content' => $_POST['content'] ) ); 531 $activity_id = bp_activity_post_update( 532 array( 533 'content' => $_POST['content'], 534 'error_type' => 'wp_error', 535 ) 536 ); 540 537 541 538 } elseif ( 'group' === $object ) { … … 544 541 $activity_id = groups_post_update( 545 542 array( 546 'content' => $_POST['content'], 547 'group_id' => $item_id, 543 'content' => $_POST['content'], 544 'group_id' => $item_id, 545 'error_type' => 'wp_error', 548 546 ) 549 547 ); … … 566 564 } 567 565 568 if ( empty( $activity_id ) ) { 566 if ( is_wp_error( $activity_id ) ) { 567 wp_send_json_error( 568 array( 569 'message' => $activity_id->get_error_message(), 570 ) 571 ); 572 } elseif ( empty( $activity_id ) ) { 569 573 wp_send_json_error( 570 574 array(
Note: See TracChangeset
for help on using the changeset viewer.