Ok, I’ve completely done it ?? This is the code:
/**
* THIS IS WHERE WE ACTUALLY SAVE THE ACTIVITY UPDATE.
*/
function ajax_update_activity_contents () {
$bpfb_code = $activity = '';
$aid = 0;
$codec = new BpfbCodec;
if (@$_POST['data']['bpfb_video_url']) {
$bpfb_code = $codec->create_video_tag($_POST['data']['bpfb_video_url']);
$type = 'bpfb_share_link';
}
if (@$_POST['data']['bpfb_link_url']) {
$bpfb_code = $codec->create_link_tag(
$_POST['data']['bpfb_link_url'],
$_POST['data']['bpfb_link_title'],
$_POST['data']['bpfb_link_body'],
$_POST['data']['bpfb_link_image']
);
$type = 'bpfb_share_link';
}
if (@$_POST['data']['bpfb_photos']) {
$images = $this->move_images($_POST['data']['bpfb_photos']);
$bpfb_code = $codec->create_images_tag($images);
$type = 'bpfb_share_wall_photos';
}
$bpfb_code = apply_filters('bpfb_code_before_save', $bpfb_code);
// All done creating tags. Now, save the code
$gid = (int)@$_POST['group_id'];
if ($bpfb_code) {
global $bp;
$content = @$_POST['content'] . "\n" . $bpfb_code;
$content = apply_filters('bp_activity_post_update_content', $content);
$user_id = $bp->loggedin_user->id;
$userlink = bp_core_get_userlink( $user_id );
$author = bp_core_get_userlink( $author_id );
$activity_url = bp_activity_get_permalink( $item_id );
$aid = $gid ?
groups_post_update(array('content' => $content, 'group_id' => $gid))
:
// Acá intercepto el envío y lo customizo para poder discriminar tipos diferentes de actividad =D @Juanma
//bp_activity_post_update(array('content' => $content))
bp_activity_add(
array(
'action' => apply_filters( 'activity_update', sprintf( __( '%s compartió un enlace', 'buddypress' ), $userlink ), $user_id ),
'content' => $content,
'component' => 'activity',
'type' => $type,
'user_id' => $user_id
)
)
;
And below also added the activity filters options ?? (still a bit hardcoded but):
/**
* bpfb_activity_links_filter()
*
* Adds 'Enlaces' and 'Wall Photos' to activity stream filters.
*
*/
function bpfb_activity_links_filter() {
echo '<option value="bpfb_share_link">Enlaces</option>';
echo '<option value="bpfb_share_wall_photos">Fotos del muro</option>';
}
add_action( 'bp_activity_filter_options', 'bpfb_activity_links_filter' );
add_action( 'bp_member_activity_filter_options', 'bpfb_activity_links_filter' );
add_action( 'bp_group_activity_filter_options', 'bpfb_activity_links_filter' );
Hope it helps you also, @jchew ??