Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 501 through 525 (of 32,295 total)
  • Author
    Search Results
  • #235994

    In reply to: Closed Topic

    sarenetri
    Participant

    No need to assign $topic->ID to $topic_id
    You can do just simple:

    foreach ($topics as $topic)
      chiudi_topic_dopo_24_ore($topic->ID);
    #235961
    Robin W
    Moderator

    bbpress has not had a release since November 2021, so what do you mean by ‘has lately’ – if after that, then suspect something else is now making that not work.

    You suggested cause (‘I suspect the code doing this is non-standard’) may be correct and something else is now causing this to show or it may not be bbpress causing this. Maybe look at what else has changed – wordpress, php versions, other plugins etc.

    Without knowing your set up or indeed your technical ability (although from you post this seems to be good!) I’d also initially suggest the standard fault finding :

    it could be a theme or plugin issue

    Themes

    As a test switch to a default theme such as twentytwenty, and see if this fixes.

    Plugins

    If that doesn’t work, also deactivate all plugins apart from bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.

    If you cannot do this to your site (say because it is live) then use the ‘troubleshooting’ features of this plugin to let you test without affecting other users

    Health Check & Troubleshooting

    Then come back

    #235956
    Robin W
    Moderator
    add_filter( 'bbp_get_reply_post_date', 'rew_show_time_since' , 10 , 6) ;
    add_filter( 'bbp_get_topic_post_date', 'rew_show_time_since' , 10 , 6) ;
    
    function rew_show_time_since ($result, $reply_id, $humanize, $gmt, $date, $time ){
    	$gmt_s  = ! empty( $gmt ) ? 'G' : 'U';
    	$date   = get_post_time( $gmt_s, $gmt, $reply_id );
    	$result = bbp_get_time_since( $date );
    return $result ;	
    }

    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

    #235944

    In reply to: Child theme questions

    Scordisian
    Participant

    Oh the description box and the tags. This is what I did with regard to the description box thus far:

    function change_single_topic_description_class( $output, $r, $args ) {
        $new_before = str_replace( 'bbp-template-notice info', 'alert alert-info', $r['before'] );
    
        $output = str_replace( $r['before'], $new_before, $output );
    
        return $output;
    }
    add_filter( 'bbp_get_single_topic_description', 'change_single_topic_description_class', 10, 3 );
    enkoes
    Participant

    Yes, Robin. The codes run without any error. Appreciated your effort in helping me to solve the issue.

    #235930

    Topic: Child theme questions

    in forum Themes
    Scordisian
    Participant

    I am finishing a Bootstrap 5 theme and I have some questions about the child theme structure.
    From what I can asses using BBpress theme as a child theme is by doing the following:

    Copy all the template/default/bbpress files into my /childtheme/bbpress folder. This works smoothly and I am happily converting and theming.

    But, the class “bbp-breadcrumb” is located in the /includes/common/template.php file.
    And the class “bbp-template-notice info” is located in the /includes/forumss/template.php file.

    How would I go about to move this behavior to my childtheme? Copy those files there or add code to the functions.php file or something similar?

    Any pointers are appreciated!

    #235926
    nikdow
    Participant

    We have ~30 WP sites on a server.
    We store plugins in a central directory and slink to them from each website that uses that plugin.
    (Reason: saves a lot of memory in OPCache & saves compiling the code more than once.)
    This relies on plugins being well-behaved. bbpress used to work but has lately broken.
    We are seeing this error:
    Loading failed for the <script> with source https://www.otu.asn.au/home/lamp/wordpress/plugins/bbpress/templates/default/js/editor.min.js?ver=2.6.9
    What it should be trying to load:
    https://www.otu.asn.au/wp-content/plugins/bbpress/templates/default/js/editor.min.js?ver=2.6.9
    Obviously the plugin is using the filepath to construct the loading URL, I suspect the code doing this is non-standard, causing the problem.

    Temporary solution is to load the plugin into the wp-content directory of the site, rather than using the slink. This has been implemented but means that the plugin won’t update. (We do updates outside of WP using python/SVN, and apache doesn’t have write access to any directories that contain PHP files – more secure). Fortunately we don’t use the plugin on any other sites.

    Robin W
    Moderator

    if ($user_role == 'bbp_prime_moderator') unset ($links['edit']) ;

    for custom roles, you just name the role itself.,

    enkoes
    Participant

    There it is:
    $bbp_roles['bbp_prime_moderator'] = array(

    I’ve tried the two options below but both return errors:
    if ($user_role == bbp_get_bbp_prime_moderator_role()) unset ($links['edit']) ;
    if ($user_role == bbp_get_prime_moderator_role()) unset ($links['edit']) ;

    Robin W
    Moderator

    ok, so what is the role on this line

    $bbp_roles['bbp_tutor'] = array(

    and what is the code you have added in the code above?

    enkoes
    Participant

    Yes. It works beautifully! 🙂

    I just found out something when I thought the issue is solved. The code works well with native bbpress role, but not work with new role created. I have a new role “prime_moderator” created using your plugin, but the code return error when I apply this new role to the codes. Any suggestions?

    Regards.

    Robin W
    Moderator

    sorry, try this

    add_filter ('bbp_reply_admin_links', 'rew_remove_edit') ;
    add_filter ('bbp_topic_admin_links', 'rew_remove_edit') ;
    
    function rew_remove_edit ($links) {
    $user_id = bbp_get_current_user_id() ;
    $user_role = bbp_get_user_role( $user_id );
    if ($user_role == bbp_get_keymaster_role()) unset ($links['edit']) ;
    if ($user_role == bbp_get_moderator_role()) unset ($links['edit']) ;
    if ($user_role == bbp_get_participant_role()) unset ($links['edit']) ;
    if ($user_role == bbp_get_spectator_role()) unset ($links['edit']) ;
    if ($user_role == bbp_get_blocked_role()) unset ($links['edit']) ;
    return $links ;	
    }
    enkoes
    Participant

    Hi Robin, thanks for your prompt reply.

    The code does not work. Perhaps something missing?

    I only take this
    if ($user_role == bbp_get_moderator_role()) unset ($links['edit']) ;
    When moderator log in, he still can see the “edit” link.

    Regards.

    Robin W
    Moderator
    add_filter ('bbp_reply_admin_links', 'rew_remove_edit') ;
    add_filter ('bbp_topic_admin_links', 'rew_remove_edit') ;
    
    function rew_remove_edit ($links) {
    $user_role = bbp_get_user_role( $user_id );
    if ($user_role == bbp_get_keymaster_role()) unset ($links['edit']) ;
    if ($user_role == bbp_get_moderator_role()) unset ($links['edit']) ;
    if ($user_role == bbp_get_participant_role()) unset ($links['edit']) ;
    if ($user_role == bbp_get_spectator_role()) unset ($links['edit']) ;
    if ($user_role == bbp_get_blocked_role()) unset ($links['edit']) ;
    return $links ;	
    }

    and amend as needed

    spectator and blocked not really needed as neither can post, but included for completeness !!

    enkoes
    Participant

    Hi, I’m using the codes below to remove “Edit” link in reply header without any issue:

    add_filter ('bbp_reply_admin_links', 'rew_remove_edit') ;
    add_filter ('bbp_topic_admin_links', 'rew_remove_edit') ;
    
    function rew_remove_edit ($links) {
    	unset ($links['edit']) ;
    return $links ;	
    }

    My question: If I want the codes to work only for Role A & Role B, but NOT for other roles, how would I amend the code above?

    Regards.

    #235873
    Robin W
    Moderator

    I just had a quick look at the yoast code, and this is deliberate.

    a comment in the yoast code says :

    If breadcrumbs are active (which they supposedly are if the users has enabled this settings),
    		 * there's no reason to have bbPress breadcrumbs as well.
    salvagedwisdom
    Participant

    WordPress v. 6.2.2
    BBPress v. 2.6.9
    Site (under construction): https://www.batsandblacklace.com

    I am able to use the forum index shortcode while I’m editing my forums page and everything looks perfect (first screenshot). On the front end however, it looks completely different and is completely unusable (second screenshot). I have driven myself insane trying to figure this out and I’m coming up completely empty. Does anyone know what’s going on here?

    Thanks!

    Screenshot 1
    Screenshot 2

    #235863

    In reply to: How to add search bar?

    Robin W
    Moderator
    function bbptoolkit_show_search_form(){
    	if ( bbp_allow_search()) {
    			?>
    			<div class="bbp-search-form">
    				<?php bbp_get_template_part( 'form', 'search' ); ?>
    			</div>
    			<?php
    		}
    	}
    	
    add_action( 'bbp_template_before_single_forum', 'bbptoolkit_show_search_form' );
    add_action( 'bbp_template_before_single_topic', 'bbptoolkit_show_search_form' );

    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

    #235835

    In reply to: Template

    loftus49
    Participant

    Many thanks (again). I’ll use the shortcode to resolve this, as you suggest.

    Another SOLVED and CLOSED issue.

    #235834

    In reply to: Template

    Robin W
    Moderator

    ok these are instructions from 12 years ago, and are not applicable for the current version of bbpress.

    If you just enable the ‘anyone can register’, then users can register from either the topic/reply forms, or you can use a register page – ie create a page – call it whatever you want and put the shortcode [bbp-register] in it. Then add this page to your menu.

    #235796
    enkoes
    Participant

    Oh ok. Thanks.

    Now I shifted back to [bbp-topic-index] and limit the number of displayed topics in WordPress dashboard setting>forum. And it finally displays page number.

    #235784
    Robin W
    Moderator

    from memory I have not written that one with pagination as the bbpress one does that for pages where you want lots to show, but does just have 15 as the only option

    [bbp-topic-index]

    #235781
    enkoes
    Participant

    Hi,

    It seems that I have problem with pagination display.

    I use shortcode [bsp-display-topic-index show=‘30’] to display the topic list. I have currently 15 topics so far, and display looks fine:

    Viewing 15 topics - 1 through 15 (of 15 total)

    But when I change the shortcode to [bsp-display-topic-index show=‘10’], my total number of topics also being reduced:

    Viewing 10 topics - 1 through 10 (of 10 total)

    And I don’t see any pages number 1,2

    Somewhere gone wrong?

    Regards.

    #235775

    Topic: Closed Topic

    in forum Troubleshooting
    Devcr3
    Participant

    I wrote this code to close the topics (specific forum) after 24h. It’s right?

    // Funzione per chiudere automaticamente i topic dopo 24 ore
    function chiudi_topic_dopo_24_ore($topic_id) {
    // Ottenere la data di creazione del topic
    $topic_date = get_post_field(‘post_date’, $topic_id);

    // Calcolare la data e l’ora attuali
    $current_date = current_time(‘mysql’);

    // Calcolare la differenza in ore tra la data di creazione del topic e l’ora attuale
    $hours_diff = round((strtotime($current_date) – strtotime($topic_date)) / (60 * 60));

    // Se sono passate 24 ore, chiudere il topic
    if ($hours_diff >= 24) {
    bbp_close_topic($topic_id);
    }
    }
    add_action(‘bbp_new_topic’, ‘chiudi_topic_dopo_24_ore’);

    // Funzione per chiudere automaticamente i topic esistenti dopo 24 ore
    function chiudi_topic_esistenti_dopo_24_ore() {
    // Ottenere tutti i topic del forum specifico
    $args = array(
    ‘post_type’ => bbp_get_topic_post_type(),
    ‘post_parent’ => ‘YOUR_FORUM_ID’, // l’ID del forum
    ‘posts_per_page’ => -1,
    );
    $topics = get_posts($args);

    // Chiudere i topic che hanno superato le 24 ore
    foreach ($topics as $topic) {
    $topic_id = $topic->ID;
    chiudi_topic_dopo_24_ore($topic_id);
    }
    }
    add_action(‘init’, ‘chiudi_topic_esistenti_dopo_24_ore’);

    #235734
    zoddshop63
    Participant

    bbpress doesnt send any emails… activation emails, forgot password, subscription, etc..
    the page bbp-register shortcode has register option which sends an email but since no email is sent no user can register.

Viewing 25 results - 501 through 525 (of 32,295 total)
Skip to toolbar