Skip to:
Content
Pages
Categories
Search
Top
Bottom

Update Topic On Reply


  • ljmac
    Participant

    @ljmac

    Hello,

    Can somebody give me a simple function to update bbpress topics when a reply to it is posted? i.e. The equivalent of hitting the update button on the topic when a reply is posted to it.

Viewing 8 replies - 1 through 8 (of 8 total)

  • Robin W
    Moderator

    @robin-w

    sorry, can you explain further.

    There is no ‘update’ button on a topic unless this is lost in translation, there is edit and submit.

    can you detail a series of steps and what you want to happen?


    ljmac
    Participant

    @ljmac

    Okay, I mean the submit button. I just want the topic to be updated (as if I was hitting the submit button) when a reply is posted, that’s all.


    Robin W
    Moderator

    @robin-w

    sorry, still need more.

    Do you mean that you don’t want anyone to have replies, but instead replies by anyone to update topic content and not leave a reply ?


    ljmac
    Participant

    @ljmac

    I do not want the standard behaviour to be modified in any way, except that the topic itself be updated when a reply is posted to it. Nothing will look any different to standard bbpress behaviour as far as the user is concerned – I just want to simulate hitting the submit button on the topic when a reply is posted, nothing more.


    Robin W
    Moderator

    @robin-w

    sorry, I am trying to help you, but am still unclear what it is you want.

    Can you define what you mean by ‘updated’??


    ljmac
    Participant

    @ljmac

    Like I said, as if I was hitting the submit button on the topic. There won’t actually be anything new within the topic itself, I just want it to be updated, as if it was saved but without any actual changes in the topic itself. I simply want a reply to the topic to trigger a save within the topic itself. I think you’re thinking I must be wanting something more complicated, but it really is that simple.


    Robin W
    Moderator

    @robin-w

    ok, I now understand what you want.

    Put this in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

    where %your-theme-name% is the name of your theme

    or use

    Code Snippets

    add_action ('bbp_new_reply_post_extras' , 'rew_update_topic') ;
    add_action ('bbp_edit_reply_post_extras' , 'rew_update_topic') ;
    
    function rew_update_topic ($reply_id) {
    	$topic_id = bbp_get_reply_topic_id( $reply_id );
    	$topic_data = apply_filters( 'rew_update_topic', array(
    		'ID'           => $topic_id,
    	) );
    
    $topic_id = wp_update_post( $topic_data );
    }

    ljmac
    Participant

    @ljmac

    Thank you very much!

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Skip to toolbar