Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 601 through 625 (of 32,358 total)
  • Author
    Search Results
  • #235471
    Robin W
    Moderator

    thanks for that, now totally understand.

    Given that you have about 100 to do and they are in separate files, it would take longer to write the code, transfer the files and then run the code through them, than to just manually copy/paste into topics.

    sorry, I know it is boring, but it is probably the best way.

    do 10 in the morning and 10 in the evening each day, and in a week it’ll be done

    dozza
    Participant

    I have a memberpress/bbPress/Wordpress site with about 100 members. I was trying to make a user a moderator of a particular forum. I was able to change her role to a moderator by editing her user profile OK. But when I add her username to the moderator field within the edit forum screen it spins on update but never registers the username as moderator.

    I then notice the username in question is of the format ‘firstname dot space secondname’

    I didn’t think WP allowed usernames with spaces or dots (periods) but apparently, it does and the username is created when they register via a Memberpress form. By default, they are made forum participants upon registering. I want to upgrade this user to be a moderator of a specific forum.

    The user HAS managed to post a topic in a forum already as a participant.

    So i’m assuming that the problem lies in bbPress NOT allowing spaces in usernames when you try to assign them to be a moderator of a specific forum?

    I was reading a 15 year old thread here where @howtogeek provides some plugin code. I tried saving this to a zipped .php file and adding it as a plugin but Wordfence said that wasn’t a good idea, so I’m not confident using 15-year old code is such a good workaround.

    There was another old thread from 8yrs here ago where @joop.stringer suggests tweaking permalinks but I can’t seem to figure that out either.

    I’ve come across this which will maybe help me prevent this from happening again.

    But can anyone confirm that the space in the username IS the reason I can’t assign a moderator
    role user to be the moderator of a specific forum, and if there is any more recent knowledge on this issue? i.e. does bbPress actually allow spaces in usernames now?

    #235357
    Rough Pixels
    Participant

    Thanks, Robin for the plugin suggestion, but it’s more of the core of bbPress which seems quite outdated and a little messy with code. Plus, doing template overrides, there are things which hoped would be there that I can override. Some styles are using!important, some styles are reused in ways they shouldn’t be, so I had to get creative with overrides…I had to use javascript to remove/change/add classes to select elements: ie buttons.

    Then, on the bbpress plugin page at .org, this shows up as a notice:

    This plugin hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

    Time to revamp this plugin and bring the coding and features up-to-date–plus capabilities. Even here in this forum, the font size is just 12 px. Time to move it up a bit, especially for accessibility 🙂

    #235344

    In reply to: Close topic label

    wpturk
    Participant

    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);
    #235334

    In reply to: Close topic label

    enkoes
    Participant

    You’re right. This code does not work in my theme. Well, think we just put this part on hold first.

    Next, I want to change font label [Closed] to RED colour. Can we do that?

    Regards.

    #235330

    In reply to: Close topic label

    wpturk
    Participant

    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');
    #235329
    Robin W
    Moderator

    sorry, that reads as being rude, it is not intended to be – written to try and be helpful whilst buried in code 🙂

    Please do report back, I’ll try and make a note here when I release it, but probably a week or so’s time .

    #235327
    Robin W
    Moderator

    it would, but I am just a man in his kitchen, I’m not a bbpress author.

    Style pack is much more than just styling (it may have been mostly that when you tried it), and you don’t need to use the styling bits to take advantage of the functionality.

    Anyway it’s free and what I write, so that’s where the blocks will be.

    If you just want to use blocks in the custom post types, then just add this filter

    add_filter ('bbp_register_forum_post_type', 'rew_gutenberg_editor') ;
    add_filter ('bbp_register_topic_post_type', 'rew_gutenberg_editor') ;
    add_filter ('bbp_register_reply_post_type', 'rew_gutenberg_editor') ;
    
    function rew_gutenberg_editor ($settings) {
    	$settings['show_in_rest'] = true ;
    	return $settings ;
    }

    If you want to impose blocks on your users in topics and replies, then use the ‘blocks everywhere’ plugin.

    If you want block widgets, that is what will be in style pack when I have finished writing it.

    If you want bbpress in FSE themes, that will also be in style pack in due course

    Robin W
    Moderator

    instructions for them

    find
    wp-content/plugins/bbpress/templates/default/bbpress/form-topic.php

    transfer this to your pc and edit

    go to line 248 and change

    ? esc_html_e( 'You cannot create new topics.', 'bbpress' )

    to

    ? esc_html_e( '', 'bbpress' )

    and save

    create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

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

    Then transfer the file you saved above and put in in the directory called bbpress that you created above, so you end up with
    wp-content/themes/%your-theme-name%/bbpress/form-topic.php

    bbPress will now use this template instead of the original

    #235318

    In reply to: Close topic label

    enkoes
    Participant

    Hi, thanks a lot! … feel amazed to see how coding can do the changes to our forum layout.

    This code just works fine in topic listing page.

    For topic page, it would be perfect if user can still see the [Closed] label beside the topic title.
    See https://paste.pics/N5WS0

    Regards.

    #235314
    wpturk
    Participant

    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

    #235313
    nextlevelg
    Participant

    Just installed the plugin and it seems to have some issues with order tracking for woocommerce plugin since it is showing a shortcode of this last plugin on the forums root page (https://nextlevelgamingstore.com/forums/), and Im not even being able to edit this page or something. How can I fix that or just edit the forums root page? Also I would like to have the forums root in a page so I can edit it.

    #235311

    In reply to: Close topic label

    wpturk
    Participant

    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);
    #235294

    In reply to: Close topic label

    enkoes
    Participant

    Hi, do u mean we replace
    add_filter ('the_title' , 'rew_add_close_to_topics') ;

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

    #235289

    In reply to: Close topic label

    wpturk
    Participant

    You can use

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

    #235241

    In reply to: Close topic label

    Robin W
    Moderator

    I’ll add this functionality to style pack in a few days, but in the meantime

    add_filter ('the_title' , 'rew_add_close_to_topics') ;
    
    function rew_add_close_to_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 ;	
    }

    and amend words/position etc. as you wish.

    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

    and change the background of the closed block to match your theme

    #235238

    In reply to: Customizing lead topic

    Robin W
    Moderator

    so is this with this function installed?

    add_filter ('bbp_get_topic_post_date' , 'rew_change_to_freshness', 10 , 6) ;
    add_filter ('bbp_get_reply_post_date' , 'rew_change_to_freshness', 10 , 6) ;
    
    function rew_change_to_freshness ($result, $topic_id, $humanize, $gmt, $date, $time) {
    	$result = bbp_get_time_since( bbp_convert_date( $time ) ) ;
    	
    return $result ;
    }
    #235229
    wpturk
    Participant

    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.

    #235223
    wpturk
    Participant

    🙂

    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');
    #235221
    wpturk
    Participant

    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');
    #235208
    wpturk
    Participant

    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 );
    #235189
    Philippe Roussel
    Participant

    No, that doesn’t do anything. I asked the question to the plugin author a few days ago but got no answer. One last request regarding the code you gave me earlier on: How can I insert an external link in my [TEXT]?

    #235182
    wpturk
    Participant

    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 ' ';
     }
    #235177
    Philippe Roussel
    Participant

    Hi,

    I use the Post Comments as bbPress Topics plugin, which gives by default an excerpt of the concerned post. None of the other options seem to work but none of them suit me either. Expanding on the php code you gave earlier in this thread, would it be possible to simply delete all content in the topic other than “[See the full post at: …]” and, of course, my own [TEXT]?

    Thank you

    #235166

    In reply to: Formatted text

    wpturk
    Participant

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

    add_filter ('bbp_get_reply_content', 'aa_stripped_content');

Viewing 25 results - 601 through 625 (of 32,358 total)
Skip to toolbar