Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter luiz-armesto

    (@luiz-armesto)

    Great news. I’ll be waiting the new release ??

    Thread Starter luiz-armesto

    (@luiz-armesto)

    Hi Marius Ooms. I’m a Brazilian developer who started to use BuddyPress and WordPress two months ago to implement the social networking site to one local project. Until now I was working creating a theme and studying the BuddyPress/WordPress API and source code.

    I’m not active in BuddyPress community yet, but I’m willing to give back to community all improvements and fixes done by the team I’m working with. As the integration between blogs and groups is a important feature to our project this was the first contribution.

    I’ll credit the team member who worked on each contribution I’ll send, and encourage them to publish their own improvements, but this was done by myself ??

    By the way, you will have a Brazilian Portuguese translation for this plugin soon.

    Cheers

    Thread Starter luiz-armesto

    (@luiz-armesto)

    That’s true, with that function we duplicate the entry. I tried to remove the original one, but it will break the “Recent Site Wide Posts” widget.

    Then I used a new approach, ‘why create a new one and remove the original if we can modify the original?’

    So, my new suggestion is to remove and forget the previous function I sent and try this

    /**
     * bp_groupblog_set_group_to_post_activity ( $activity )
     *
     * Record the blog activity for the group.
     */
    function bp_groupblog_set_group_to_post_activity( $activity ) {
    
    	if ( $activity->type != 'new_blog_post') return;
    
    	$blog_id = $activity->item_id;
    	$post_id = $activity->secondary_item_id;
    	$post = get_post( $post_id );
    
    	$group_id = get_groupblog_group_id( $blog_id );
    	if ( !$group_id ) return;
    	$group = new BP_Groups_Group( $group_id, true );
    
    	// Verify if we already have the modified activity for this blog post
    	$id = bp_activity_get_activity_id( array(
    		'user_id' => $activity->user_id,
    		'type' => $activity->type,
    		'item_id' => $group_id,
    		'secondary_item_id' => $activity->secondary_item_id
    	) );
    
    	// if we don't have, verify if we have an original activity
    	if ( !$id ) {
    		$id = bp_activity_get_activity_id( array(
    			'user_id' => $activity->user_id,
    			'type' => $activity->type,
    			'item_id' => $activity->item_id,
    			'secondary_item_id' => $activity->secondary_item_id
    		) );
    	}
    
    	// If we found an activity for this blog post then overwrite that to avoid have multiple activities for every blog post edit
    	if ( $id ) $activity->id = $id;
    
    	// Replace the necessary values to display in group activity stream
    	$activity->action = sprintf( __( '%s wrote a new blog post %s in the group %s:', 'groupblog'), bp_core_get_userlink( $post->post_author ), '<a href="' . get_permalink( $post->ID ) .'">' . attribute_escape( $post->post_title ) . '</a>', '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' );
    	$activity->item_id = $group_id;
    	$activity->component = 'groups';
    	$activity->hide_sitewide = 0;
    
    }
    add_action( 'bp_activity_before_save', 'bp_groupblog_set_group_to_post_activity');

    Edit: *** Issue fixed ***

Viewing 3 replies - 1 through 3 (of 3 total)