bp_activity_action_post_update()
Post user/group activity update.
Description
Return
(bool) False on failure.
Source
File: bp-activity/actions/post.php
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | function bp_activity_action_post_update() { // Do not proceed if user is not logged in, not viewing activity, or not posting. if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'post' ) ) return false; // Check the nonce. check_admin_referer( 'post_update' , '_wpnonce_post_update' ); /** * Filters the content provided in the activity input field. * * @since BuddyPress 1.2.0 * * @param string $value Activity message being posted. */ $content = apply_filters( 'bp_activity_post_update_content' , $_POST [ 'whats-new' ] ); if ( ! empty ( $_POST [ 'whats-new-post-object' ] ) ) { /** * Filters the item type that the activity update should be associated with. * * @since BuddyPress 1.2.0 * * @param string $value Item type to associate with. */ $object = apply_filters( 'bp_activity_post_update_object' , $_POST [ 'whats-new-post-object' ] ); } if ( ! empty ( $_POST [ 'whats-new-post-in' ] ) ) { /** * Filters what component the activity is being to. * * @since BuddyPress 1.2.0 * * @param string $value Chosen component to post activity to. */ $item_id = apply_filters( 'bp_activity_post_update_item_id' , $_POST [ 'whats-new-post-in' ] ); } // No activity content so provide feedback and redirect. if ( empty ( $content ) ) { bp_core_add_message( __( 'Please enter some content to post.' , 'buddyboss' ), 'error' ); bp_core_redirect( wp_get_referer() ); } // No existing item_id. if ( empty ( $item_id ) ) { $activity_id = bp_activity_post_update( array ( 'content' => $content ) ); // Post to groups object. } elseif ( 'groups' == $object && bp_is_active( 'groups' ) ) { if ( (int) $item_id ) { $activity_id = groups_post_update( array ( 'content' => $content , 'group_id' => $item_id ) ); } } else { /** * Filters activity object for BuddyPress core and plugin authors before posting activity update. * * @since BuddyPress 1.2.0 * * @param string $object Activity item being associated to. * @param string $item_id Component ID being posted to. * @param string $content Activity content being posted. */ $activity_id = apply_filters( 'bp_activity_custom_update' , $object , $item_id , $content ); } // Provide user feedback. if ( ! empty ( $activity_id ) ) bp_core_add_message( __( 'Update Posted!' , 'buddyboss' ) ); else bp_core_add_message( __( 'There was an error when posting your update. Please try again.' , 'buddyboss' ), 'error' ); // Redirect. bp_core_redirect( wp_get_referer() ); } |
Changelog
Version | Description |
---|---|
BuddyPress 1.2.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.