Skip to:
Content
Pages
Categories
Search
Top
Bottom

To Core developers: forum post id question

  • I guess this question is to someone knowledgeable with the inner works of BP.

    I’m working on extending BP forum topic/reply forms with additional fields. To do this, I’m hook an extra template to the forms in the following way:

    	add_action( 'groups_forum_new_topic_after', 'e2_include_forum_extras_form' );
    add_action( 'bp_after_group_forum_post_new', 'e2_include_forum_extras_form' );
    add_action( 'bp_group_after_edit_forum_topic', 'e2_include_forum_extras_form' );
    add_action( 'bp_group_after_edit_forum_post', 'e2_include_forum_extras_form' );
    
    function e2_include_forum_extras_form() {
    locate_template( array( 'forums/forum-extras.php' ), true );
    }
    

    The problem is: when editing an existing forum post, how do I access the id of the currently edited post within forum-extras.php? One would think that bp_get_the_topic_post_id() would be the right function, but this returns null if used within edit forms.

    I have tested the following on the topic edit form:

    
    bp_get_the_topic_post_id() ==  // This appears to be empty!
    bp_get_the_topic_id() == "52"/groups/aviation/forum/topic/this-is-a-new-topic-with-4-pictures/edit?_wpnonce=740fc2405c  // Why this value, and not a proper ID?
    bp_is_edit_topic() == 1  // Tells if this is a topic or reply edit
    bp_is_group_forum_topic_edit() == 1 // True for both topic end reply edit
    $forum_template->topic == {"topic_id":"52","topic_title":"This is a new topic with 4 pictures","topic_slug":"this-is-a-new-topic-with-4-pictures","topic_poster":"1","topic_poster_name":"admin","topic_last_poster":"1","topic_last_poster_name":"admin","topic_start_time":"2011-09-21 21:50:55","topic_time":"2011-09-21 21:51:48","forum_id":"3","topic_status":"0","topic_open":"1","topic_last_post_id":"82","topic_sticky":"0","topic_posts":"4","tag_count":"0","object_id":"2","object_name":"Aviation","object_slug":"aviation","voices_count":"1"}
    // You can get topic_id from this object
    $topic_template->post == null
    // This in null, too - so no post id
    

    Can anyone help ?
    /Martin

Viewing 1 replies (of 1 total)
  • Today, I have also tried
    `$bb_post->post_id `
    ..the $bb_post variable is available when editing the topic, but NOT when editing a reply, where it would be most needed… if find this EXTREMELY confusing. I’m lost!

Viewing 1 replies (of 1 total)
  • The topic ‘To Core developers: forum post id question’ is closed to new replies.
Skip to toolbar