wpturk (@wpturk)

Forum Replies Created

Viewing 25 replies - 1 through 25 (of 104 total)
  • In reply to: Close topic label

    wpturk
    Participant

    @wpturk

    Here we go:

    function rew_add_close_to_topics () {
    
            if ( bbp_is_topic_closed()) {
                    echo '<span style="color:red">[Closed]</span> ' ;
            }
    }
    add_action ('bbp_theme_before_topic_title' , 'rew_add_close_to_topics', 15);
    In reply to: Close topic label

    wpturk
    Participant

    @wpturk

    Hi, I am glad the code helped you.

    To attach label to the topic title on the topic page, you can try @robin ‘s code with a minor change. (below) This may not work in all themes since the title is coming from a template file.

    function rew_add_close_to_the_topics ($title) {
    
            if ( bbp_is_topic_closed()) {
                    $closed = '[Closed]' ;
                    $sep = ' ' ;
                    $position = 'after' ;
                    if (($position == 'before') && !str_contains($title, $closed)) $title = $closed.$sep.$title ;
                    if (($position =='after') && !str_contains($title, $closed)) $title = $title.$sep.$closed ;
            }
    return $title ;
    }
    add_filter ('single_post_title' , 'rew_add_close_to_the_topics');

    wpturk
    Participant

    @wpturk

    You can create a new page and put [bbp-forum-index] in it. This way, it will be your forum root page and you can edit this page.

    Here is the related documentation: 3. Creating a forum page -> Method 2

    Step by step guide to setting up a bbPress forum – Part 1

    In reply to: Close topic label

    wpturk
    Participant

    @wpturk

    No, you can not use the same snippet, since these are different hooks. You can use:

    function rew_add_close_to_topics () {
    
            if ( bbp_is_topic_closed()) {
                    echo '[Closed] ' ;
            }
    }
    add_action ('bbp_theme_before_topic_title' , 'rew_add_close_to_topics', 15);
    In reply to: Close topic label

    wpturk
    Participant

    @wpturk

    You can use

    add_action ('bbp_theme_before_topic_title' , 'rew_add_close_to_topics', 15);


    wpturk
    Participant

    @wpturk

    Probably, your theme or one of your plugin is already modifying external links to add “nofollow” attributes etc … and simultaneously breaking target="_blank" … Difficult to say before checking your theme and all your plugins. I would remove target="_blank" if it’s not working.


    wpturk
    Participant

    @wpturk

    🙂

    function add_custom_content($content) {
    
        $topic_id = bbp_get_topic_id();
        $user_id = bbp_get_topic_author_id( $topic_id );
    
        if ( bbp_is_user_keymaster($user_id) ) {
    
                $after ='<p><i>Still struggling with your website(s) speed? Click <strong><a href="https://example.com/" target="_blank">here</a></strong>.</i></p>';
                $content = $content . $after;
        }
        return $content;
    }
    add_filter ('bbp_get_topic_content', 'add_custom_content');

    wpturk
    Participant

    @wpturk

    you have to be careful with the quotation marks:

    function add_custom_content($content) {
    
        $topic_id = bbp_get_topic_id();
        $user_id = bbp_get_topic_author_id( $topic_id );
    
        if ( bbp_is_user_keymaster($user_id) ) {
    
                $after ='<p><i>Still struggling with your website(s) speed? Click <a href="https://example.com/">here</a>.</i></p>';
                $content = $content . $after;
        }
        return $content;
    }
    add_filter ('bbp_get_topic_content', 'add_custom_content');

    wpturk
    Participant

    @wpturk

    You can change the $before and $after variables to whatever you like. For example an external link before all topics:

    function add_custom_content($content) {
    
        $topic_id = bbp_get_topic_id();
        $user_id = bbp_get_topic_author_id( $topic_id );
    
        if ( bbp_is_user_keymaster($user_id) ) {
    
                $before ='<p>This is my <a href="https://bbpress.org/">EXTERNAL LINK</a>.</p>';
                $after ='<p>TEXT AFTER</p>';
                $content = $before . $content . $after;
        }
        return $content;
    }
    add_filter ('bbp_get_topic_content', 'add_custom_content');

    For the excerpt issue you can give a try with another priority:

    function filter_the_excerpt( ) {
        return ' ';
    }
    add_filter( 'the_excerpt', 'filter_the_excerpt', 999, 2 );

    wpturk
    Participant

    @wpturk

    Hi, I’ve not used this plugin so I don’t know how it works.

    Maybe the plugin is using the WordPress excerpt, you can try this:

    add_filter( 'the_excerpt', 'filter_the_excerpt', 10, 2 );
        function filter_the_excerpt( ) {
        return ' ';
     }
    In reply to: Formatted text

    wpturk
    Participant

    @wpturk

    you need this additional line if you want to strip replies too:

    add_filter ('bbp_get_reply_content', 'aa_stripped_content');

    In reply to: Formatted text

    wpturk
    Participant

    @wpturk

    you are welcome!

    In reply to: Formatted text

    wpturk
    Participant

    @wpturk

    Hi, mostly formatting comes with copy-paste of html text. If you want to strip html from the text you can make use of some WordPress functions: wp_strip_all_tags(), convert_chars() etc …

    ex:

    function aa_stripped_content($content) {
        
        $content = wp_strip_all_tags($content);
        return $content;
    }
    add_filter ('bbp_get_topic_content', 'aa_stripped_content'); 

    wpturk
    Participant

    @wpturk

    you are welcome 👍


    wpturk
    Participant

    @wpturk

    As I guessed, it’s coming from your theme

    You can try this: (it’s not tested)

    function aa_profile_title ( $title, $id ) {
    
            if ( bbp_is_single_user_profile() && empty(get_post_type($id)) ) {
    
                    $author_id = bbp_get_displayed_user_field('ID');
                    $nickname = um_get_display_name( $author_id );
                    $title = $nickname;
            }
            return $title;
    }       
    add_filter( 'the_title', 'aa_profile_title', 10, 2);

    wpturk
    Participant

    @wpturk

    A link to your website/forum can be helpful. Most probably, this header is coming from your theme.


    wpturk
    Participant

    @wpturk

    you are welcome.


    wpturk
    Participant

    @wpturk

    you have to be careful with the Quotation marks, try:

    $before ='<p style="text-align:center">TEXT BEFORE</p>';


    wpturk
    Participant

    @wpturk

    you are welcome 👍


    wpturk
    Participant

    @wpturk

    Here we go:

    function add_custom_content($content) {
    
        $topic_id = bbp_get_topic_id();
        $user_id = bbp_get_topic_author_id( $topic_id );
    
        if ( bbp_is_user_keymaster($user_id) ) {
    
                $before ="<p>TEXT BEFORE</p>";
                $after ="<p>TEXT AFTER</p>";
                $content = $before . $content . $after;
        }
        return $content;
    }
    add_filter ('bbp_get_topic_content', 'add_custom_content');
    In reply to: Related topics!

    wpturk
    Participant

    @wpturk

    I’ve played with this today.

    If you are using tags in your topics, this will print the 5 related topics based on tags.
    (You need to put this in your functions.php)

    function aa_related_topics() {
    
            $topic_id = bbp_get_topic_id();
            $tags = wp_get_post_terms( $topic_id, bbp_get_topic_tag_tax_id(), array( 'fields' => 'ids' ) );
    
            $args = array(
                    'post__not_in' => array($topic_id),
                    'post_type'  => bbp_get_topic_post_type(),
                    'posts_per_page' => 5,
                    'orderby'   => 'rand',
                    'tax_query' => array(
                            array(
                                    'taxonomy' => bbp_get_topic_tag_tax_id(),
                                    'terms'    => $tags,
                            ),
                    ),
            );
    
            $my_query = new wp_query( $args );
    
            if( $my_query->have_posts() ) {
                echo '<div id="related"><h4>Related Posts</h4>';
                    while( $my_query->have_posts() ) {
                        $my_query->the_post(); ?>
                        <div>
    
                            <h5><a href="<?php the_permalink()?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h5>
    
                        </div>
                    <?php }
                    wp_reset_postdata();
                echo '</div>';
            }
    
    }
    add_action( 'bbp_template_after_single_topic', 'aa_related_topics' ); 

    wpturk
    Participant

    @wpturk

    This would do the job. Put this in your functions.php and replace the text.

    function add_custom_content($content) {
        
        $before ="<p>TEXT BEFORE</p>";
        $after ="<p>TEXT AFTER</p>";
        $content = $before . $content . $after;
        return $content;
    }
    add_filter ('bbp_get_topic_content', 'add_custom_content'); 
    In reply to: This topic is empty

    wpturk
    Participant

    @wpturk

    Did it fix the problem? You don’t have to do it after every new post!

    In reply to: Create bloc categories

    wpturk
    Participant

    @wpturk

    👍


    wpturk
    Participant

    @wpturk

    It should be a caching issue. I see the forum full-width (without sidebar) and I am not logged-in.

Viewing 25 replies - 1 through 25 (of 104 total)