Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to close or open topic by the author ?


  • Julia
    Participant

    @sub0810

    Addding close topic select box in the reply page

    Only the moderate can set up open/close on topic status now.
    I have plan to change the author in topic to set open/close status by yourself.

    The code ongoing

    
    function my_bbp_theme_before_topic_form_submit_wrapper() {
        
        if (!current_user_can('moderate', $topic_id)) {   //  The all visitor can see open/close box
            echo '<label for="bbp_topic_status">'.esc_html_e('Topic Status:', 'bbpress').'</label><br />';
            bbp_form_topic_status_dropdown();
        }
    }
    add_action('bbp_theme_before_topic_form_submit_wrapper', 'my_bbp_theme_before_topic_form_submit_wrapper');
    
    function my_bbp_get_topic_statuses($topic_statuses, $topic_id) {
    
        //  The all visitor may be possible to chang the topic status,if the select box works.
        if (!current_user_can('moderate', $topic_id)) {
            $topic_statuses = array(
                bbp_get_public_status_id() => _x('Open', 'Open the topic', 'bbpress'),
                bbp_get_closed_status_id() => _x('Closed', 'Close the topic', 'bbpress')
            );
        }
        return $topic_statuses;
    }
    add_filter('bbp_get_topic_statuses', 'my_bbp_get_topic_statuses', 10, 2);
    

    Two questions

    1st
    The topic open/close select box is shown all visitor except for author.
    So this code need to change all vistor to topic author.
    But I don’t know.

    
    if (!current_user_can('moderate', $topic_id)) {  // All visitor can do
    ↓
    if(current_user_can( '//topic author//' ) ) {    // Only topic author can do
    

    2nd
    The select box is shown, but it doesn’t work at all.
    In short, the select box is appearance only.
    So I have to add some code to work open/colse select box.
    The select box does not link to topic status function.
    But I don’t know how to chage the code.

    
        $topic_statuses = array(
        bbp_get_public_status_id() => _x('Open', 'Open the topic', 'bbpress'),
        bbp_get_closed_status_id() => _x('Closed', 'Close the topic', 'bbpress')
        )
    
Viewing 5 replies - 1 through 5 (of 5 total)

  • Robin W
    Moderator

    @robin-w

    this option is in

    bbp style pack

    dashboard>settings>bbp style pack>Topic/Reply Display>item 17

    if you want to see the code it is in that plugin

    \bbp-style-pack\trunk\includes\functions.php

    starting at line 2066


    Julia
    Participant

    @sub0810

    Thank you for your help. Thanks to your code, I manage to set up open close button in the reply page .
    So in bbp style pack or my customized code, the open close status button sets on all comments in the reply page.
    It would be un-displayable by using CSS code except for top comment[topic author comment].

    Do you have some sample code to hide unnecessary open close status buttons by CSS(Cascading Style Sheet) ?

    Example

    
    //topic author		
    <a href="http://~   #post-1762" class="bbp-reply-header">#1762</a>
    class="bbp-topic-close-link"
    //------------------------------------------------------------------------
    //reply first
    <a href="http://~   #post-1763" class="bbp-reply-header">#1763</a>
    class="bbp-topic-close-link"
    
    #bbpress-forums  XXX.bbp-topic-close-link {
            display: none;
      }
    

    Robin W
    Moderator

    @robin-w

    I’d not spotted that it did that, it should just display on the topic !

    I’ll release a new style pack with a correction.

    If you have used my code, then this is the change at line 2098, with the lines before and after

    if ( empty( $topic ))
    		return;
    		
    //if not a topic but a reply to that topic, then return
    if (bbp_get_reply_id() != bbp_get_topic_id( (int) $r['id'] ) ) return  ;
    	
    //if participant and not their own topic, then return

    Julia
    Participant

    @sub0810

    I appreciate it.

    It works completely.

    Thank you for your genius.


    Robin W
    Moderator

    @robin-w

    🙂

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