sorry can you just clarify
Topic A
Reply B
Does topic A acquire reply B authors’s IP address, or does reply B get Topic A authors IP address ?
Topic A gets reply B Authors ip-address.
ok, I know why it is doing it, I’ll do some digging to see how to get around
your function calls
bbp_insert_reply
this function is in
/includes/replies/functions.php starts line 29
This creates the reply, and then on line 64 it has
// Update the topic
$topic_id = bbp_get_reply_topic_id( $reply_id );
if ( !empty( $topic_id ) ) {
bbp_update_topic( $topic_id );
}
bbp_update_topic
is held in
/includes/topics/functions.php starting line 818
has a check to see if you are creating or editing a topic.
if you are not editing a topic, it presumes that you are creating so starting line 884
// Update associated topic values if this is a new topic
if ( empty( $is_edit ) ) {
// Update poster IP if not editing
update_post_meta( $topic_id, '_bbp_author_ip', bbp_current_author_ip(), false );
since at that point your call via bbp_insert_reply and bbp_update_topic is NOT an edit, it assumes it is a new topic and updates with the current user IP as above.
let me think about easiest way to fix.
the quick and dirty solution is to get the topic IP before executing bbp_insert_reply and reset it afterwards
eg (untested)
$reply_data = array('post_parent'=>$post_parent, 'post_content' => $post_content);
$reply_meta = array('forum_id'=>$post_forum_id, 'topic_id' => $post_topic_id);
//get the topic IP so we can reset it later
$ip = get_post_meta( $topic_id, '_bbp_author_ip', false );
bbp_insert_reply($reply_data,$reply_meta);
//reset the topic IP
update_post_meta( $topic_id, '_bbp_author_ip', $ip, false );
I could spend a long time working out a more elegant fix, but hopefully the above will be enough !
Just wondering how the script makes the decision if I’m creating or editing a topic. Because I can’t give the $is_edit
variable a value in the bbp_insert_reply
and I give a excisting topic_id when insert a reply.. Well, maybe when I’ve more time I will look in to this and post the solution here if I find one. For now I will use your other solution.
Thanks for your help and thoughts Robin!
Just wondering how the script makes the decision if I’m creating or editing a topic.
not an area of the plugin I’ve yet delved into ! hense the quick and dirty !