Sylvain Filoni
asked 10 years ago

Hi Everybody !

I was proud i could handle it until now for almost everything but i get a tiny last issue :
When recording a new Question | Comment or Response in the Buddypress activity, it doesn’t print the right phrases, but record as it was a blog post, and a comment post …  Is it because i’m using BP 2.0 ? Or maybe i missed something ?

Thanks for your help !
 

Sylvain Filoni
replied 10 years ago

Maybe we cannot have at the same time a new_blog_post record with a specific message for questions “user asked a new question”,
and a new_blog_post record with the message ” user posted a new blog post ” ?

Sylvain Filoni
replied 10 years ago

no one on this case ? 🙁

1 Answers
Sylvain Filoni
answered 10 years ago

hi thanks for your reply !
but i still don’t see the exit … this is what i have for the recording of a question:  

function adn_record_question_activity( $post_id ) { $post = get_post($post_id);

if(($post->post_status != ‘publish’) && ($post->post_status != ‘private’)) return; $user_id = get_current_user_id(); $post_permalink = get_permalink( $post_id ); $post_title = get_the_title( $post_id ); $activity_action = sprintf( __( ‘%s asked: %s’,’buddypress’ ), bp_core_get_userlink( $user_id ), ‘<a href=”‘ . $post_permalink . ‘”>’ . $post->post_title . ‘</a>’ ); $content = $post->post_content; $hide_sitewide = ($post->post_status == ‘private’) ? true : false; bp_blogs_record_activity( array( ‘user_id’ => $user_id, ‘action’ => $activity_action, ‘content’ => $content, ‘primary_link’ => $post_permalink, ‘type’ => ‘new_blog_post’, ‘item_id’ => 0, ‘secondary_item_id’ => $post_id, ‘recorded_time’ => $post->post_date_gmt, ‘hide_sitewide’ => $hide_sitewide, )); } add_action( ‘dwqa_add_question’, ‘adn_record_question_activity’);  

The sprintf do not seems to take care of the ”  sprintf( __( ‘%s asked: %s’,’buddypress’ )  ” That’s why in the activity stream it’s recorded as a simple “article”.  I suppose i forgot something my eyes cannot see, or i’m afraid it’s a piece of knowledge i do not earn yet …    Your lights shall be very appreciated on this !   Regards 

BigHug
replied 10 years ago

Did you include two lines of code that will hook into insert post action :
add_action( ‘dwqa_add_question’, ‘nex_record_question_activity’);
add_action( ‘draft_to_publish’, ‘nex_record_question_activity’ );

Powered by DW Question & Answer Pro