Hi, does anyone know how to use gravity forms to submit a post from the frontend that uses bp_activity_add in the after form submission to update buddypress activity stream to including the thumbnail image?
Here is my code so far:
add_filter("gform_post_submission_1", "set_post_thumbnail_as", 10, 2);
function set_post_thumbnail_as($entry, $form){
//getting first image associated with the post
$post_id = $entry["post_id"];
$attachments = get_posts(array('numberposts' => '1', 'post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC'));
if(sizeof($attachments) == 0)
return; //no images attached to the post
//setting first image as the thumbnail for this post
update_post_meta( $post_id, '_thumbnail_id', $attachments[0]->ID);
// update bp activty stream content.
$activity_id = bp_activity_add( array( 'id' => $post_id, 'content' => '$attachments' ));
}
If someone could help that'd be great