Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /** wire message will become private, please note that */
- /* AJAX update posting */
- function bp_mytheme_post_update() {
- global $bp;
- /* Check the nonce */
- check_admin_referer( 'post_update', '_wpnonce_post_update' );
- if ( !is_user_logged_in() ) {
- echo '-1';
- return false;
- }
- if ( empty( $_POST['content'] ) ) {
- echo '-1<div id="message" class="error"><p>' . __( 'Please enter some content to post.', 'buddypress' ) . '</p></div>';
- return false;
- }
- if ( empty( $_POST['object'] ) && function_exists( 'bp_activity_post_update' ) ) {
- if(!bp_is_home()&&bp_is_member()){
- $content="@". bp_get_displayed_user_username()." ".$_POST['content'];
- $activity_id=bpdev_activity_post_update (array( 'content' => $content ));
- }
- else{
- $content=$_POST['content'];
- $activity_id = bp_activity_post_update( array( 'content' => $content ) );
- }
- } elseif ( $_POST['object'] == 'groups' ) {
- if ( !empty( $_POST['item_id'] ) && function_exists( 'groups_post_update' ) )
- $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 ( !$activity_id ) {
- echo '-1<div id="message" class="error"><p>' . __( 'There was a problem posting your update, please try again.', 'buddypress' ) . '</p></div>';
- return false;
- }
- if ( bp_has_activities ( 'include=' . $activity_id ) ) : ?>
- <?php while ( bp_activities() ) : bp_the_activity(); ?>
- <?php locate_template( array( 'activity/entry.php' ), true ) ?>
- <?php endwhile; ?>
- <?php endif;
- }
- add_action( 'wp_ajax_post_update', 'bp_mytheme_post_update' );
- add_action("init","mytheme_remove_original_update_func",5);
- function mytheme_remove_original_update_func(){
- remove_action( 'wp_ajax_post_update', 'bp_dtheme_post_update' );
- }
- function bpdev_activity_post_update( $args = '' ) {
- global $bp;
- $defaults = array(
- 'content' => false,
- 'user_id' => $bp->loggedin_user->id
- );
- $r = wp_parse_args( $args, $defaults );
- extract( $r, EXTR_SKIP );
- if ( empty( $content ) || !strlen( trim( $content ) ) )
- return false;
- /* Record this on the user's profile */
- $from_user_link = bp_core_get_userlink( $user_id );
- $activity_action = sprintf( __( '%s posted an update:', 'buddypress' ), $from_user_link );
- $activity_content = $content;
- $primary_link = bp_core_get_userlink( $user_id, false, true );
- /* Now write the values */
- $activity_id = bp_activity_add( array(
- 'user_id' => $user_id,
- 'action' => apply_filters( 'bp_activity_new_update_action', $activity_action ),
- 'content' => apply_filters( 'bp_activity_new_update_content', $activity_content ),
- 'primary_link' => apply_filters( 'bp_activity_new_update_primary_link', $primary_link ),
- 'component' => $bp->activity->id,
- 'type' => 'activity_update',
- 'hide_sitewide'=>1
- ) );
- /* Add this update to the "latest update" usermeta so it can be fetched anywhere. */
- //update_usermeta( $bp->loggedin_user->id, 'bp_latest_update', array( 'id' => $activity_id, 'content' => wp_filter_kses( $content ) ) );
- /* Require the notifications code so email notifications can be set on the 'bp_activity_posted_update' action. */
- require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-notifications.php' );
- do_action( 'bp_activity_posted_update', $content, $user_id, $activity_id );
- return $activity_id;
- }
- ?>
Add Comment
Please, Sign In to add comment