something like this should do it
add_filter( 'bbp_new_reply_pre_content', 'my_function' );
function my_function ($reply_content) {
$extra_text = 'hello' ;
//append extra text to the end of reply content
$reply_content.= $extra_text ;
return $reply_content ;
}
Hi Robin,
Thank you, if I add that to my functions file, it adds it to a new reply perfectly if I as admin create that new reply.
But it does not work if a guest replies (it is normal for my replies to be from guests) all replies go to moderation and at the moment, before I approve the reply by publishing I add test at the end of each content. It is when I click publish that I want it to add the text.
Regards
Clive
do you have a plugin sending them to moderation ?
No, if I remember rightly, it is set up under settings / discussions to allow anyone to post comments and all go to moderation, no-one can join so all replies are all
Sorry I lied, just found I do have a plugin bbpress moderation tools by digital arm
so how do you ‘publish’ them
eg dashboard>something>something else
and what is the status of the reply before and after?
In dashboard I see in “all replies” a pending reply.
When I click on edit, in the reply attributes box the status is Pending
I have a publish button
(this is when at the moment I add my text to the contents)
When I publish the Status changes to Publish and the button changes to update
try this
function waa_content( $content, $post_id ) {
$extra_text = 'hello' ;
//append extra text to the end of reply content
$content.= $extra_text ;
return content ;
}
add_filter( 'content_edit_pre', 'waa_content', 10, 2 );
Many Thanks Robin
I added $ to content on line 5 and it works but it also works on topics and forums, I will add a
if ($post->post_type ==’reply’){
around it, thanks again
Clive
oops must have got the IF wrong, does not work with that
the $post array does not exist in this function
try
if (get_post_type ($post_id) == bbp_get_reply_post_type() ) {
Just to update, all seems to be working so I thought I would share this. I am sure the coding is bad but it works !!
I am the only one that can create topics, I moderate all replies and want to add to the end of each reply ‘#plasticfree’ and a custom metadata value for each topic that I put in when I create a topic.
This means that the hashtag and twitter name goes out with the RSS feed to tiwtter etc.
Thank you Robin for all your help.
/***
To add #plasticfree and twitter name to reply
***/
function waa_content( $content, $post_id ){
// get the topic id
$post_id = get_the_ID();
$reply_topic_id = bbp_get_reply_topic_id( $post_id );
// get value from table
$twitname = get_post_meta( $reply_topic_id, 'bbp_twitname', true );
$twithash = '#plasticfree';
$post = get_post($id);
if ($post->post_type =='reply'){
$pos = strpos($content, '#plasticfree');
if ($pos == false) {
$content .= '<br>'. $twithash .' ' .$twitname;
}
}
return $content;
}
add_filter( 'content_edit_pre', 'waa_content', 10, 2 );
code that works is never bad !!
thanks for posting the final solution, and great that it works !