Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 951 through 975 (of 32,431 total)
  • Author
    Search Results
  • #232281
    Robin W
    Moderator
    add_filter ('bbp_get_topic_class', 'rew_author_current' , 100 , 3) ;
    add_filter ('bbp_get_reply_class', 'rew_author_current' , 100 , 3) ;
    
    function rew_author_current ($post_classes, $topic_id, $classes) {
    	$author_id = bbp_get_topic_author_id( $topic_id );
    	$current_id = get_current_user_id() ;
    	if ($author_id == $current_id) {
    		$post_classes[] = 'rew-current-user' ;
    		$post_classes = array_merge( (array) $post_classes);
    	}
    return $post_classes ;
    }

    will give you ‘rew-current-user’ as a style to add css

    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

    #232280

    In reply to: Remove Separator

    Robin W
    Moderator
    function remove_sep ($args) {
    $args['before'] = ' ' ;
    return $args ;
    }
    
    add_filter ('bbp_before_get_topic_subscribe_link_parse_args', 'remove_sep') ;

      is the code for space, so if you want 2 spaces put

    $args['before'] = '  ' ;

    #232279

    In reply to: Remove Separator

    Gomle
    Participant

    Very, very old topic – but still relevant today. This topic is searchable in google, so I’m not creating another one 😉

    The above code does unfortunately not work anymore.

    Do you have an updated code for removing the pipepline between favorite | subscribe ?

    And if you don’t – how do you actually find what to use. I’m trying to learn, but I don’t know what to look for..

    #232276
    Robin W
    Moderator

    ok, let’s just redo the whole thing

    function custom_callback( $args=array()) {
    
            // Parse arguments against default values
            $r = bbp_parse_args( $args, array(
                'select_id'    => 'bbp_topic_status',
                'select_class' => 'my-class',
                'tab'          => false,
                'topic_id'     => 0,
                'selected'     => false
            ), 'topic_open_close_select' );
    
            // Filter & return
            return apply_filters( 'custom_callback', ob_get_clean(), $r, $args );
        }
    	
    
    add_filter( 'bbp_get_form_topic_status_dropdown', 'custom_callback');
    #232274
    Robin W
    Moderator

    the ‘,2’ might be the issue, as you only then use 1, but try this

    function custom_callback($args) {
        
            $args['select_class'] = 'my-class' ;
                
           return  $args;
    
    }
    add_filter( 'bbp_get_form_topic_status_dropdown', 'custom_callback');
    #232273
    Nowarah
    Participant

    I need to add a class to the dropdown topic select_class.
    the original function is:

    function bbp_get_form_topic_status_dropdown( $args = array() ) {
    
            // Parse arguments against default values
            $r = bbp_parse_args( $args, array(
                'select_id'    => 'bbp_topic_status',
                'select_class' => 'bbp_dropdown',
                'tab'          => false,
                'topic_id'     => 0,
                'selected'     => false
            ), 'topic_open_close_select' );
    
            // Filter & return
            return apply_filters( 'bbp_get_form_topic_status_dropdown', ob_get_clean(), $r, $args );
        }

    I tired to use this but didnt work

    function custom_callback($args = array() ) {
        
            $r = bbp_parse_args( $args, array(
                
                'select_class' => 'my-class',
                
            ) );
            
            return  $r;
    
    }
    add_filter( 'bbp_get_form_topic_status_dropdown', 'custom_callback', 12, 2);
    #232269
    Robin W
    Moderator

    ok, my code does not change any roles, the user will still get the participant role.

    The plugin makes them a member of a group, and as the forum is also a member of that group, they can them see the forum. The forum’s topic permissions then let them see only their topic

    #232263
    youishih
    Participant

    Hello, I use the code above with Snippets plugin, but it doesn’t work now. 🙁

    Here is my recored video: https://www.loom.com/share/774ad802d9884113b22982c502519b17

    Do you know how to fix it?

    #232262
    youishih
    Participant

    This is my first time to create a plugin by myself. I use this tutorial to create the plugin. Then, copy the code mentioned above, and it works perfectly. Thank you!

    #232257
    codejp3
    Participant

    @robin-w or another mod – can you please delete:
    https://bbpress.org/forums/topic/template-in-block-themes/#post-232249 (#post-232249)
    https://bbpress.org/forums/topic/template-in-block-themes/#post-232250 (#post-232250)
    https://bbpress.org/forums/topic/template-in-block-themes/#post-232256 (#post-232256)
    They had issues and take up a lot of wasted space.

    Seriously done this time! No more changes/revisions! It is what it is!

    Posting a much cleaner revision of the code above.

    • This one will work with either the BBPress Style Pack plugin template (looks great!) or the default BBPress template (looks horrible!).
    • It will optionally include the required ‘template-canvas.php’ only if it’s missing.
    • It will also only affect BBPress pages, not the rest of the site.
    • It will also only affect FSE Block themes.
    • If using default BBPress templates, it includes checks for if on forum root index page and loads extras/archive-forum.php (to prevent double-listing of the forum index), and loads extras/page-front-forums.php for “the rest of bbpress” (to prevent “nothing found” errors)
    
    // function to include the wp-includes/template-canvas.php file if needed
    function fse_bbpress_template( $template ) {
    	
    	if ( is_bbpress() ) {
    	
    		$template = ABSPATH . WPINC . '/template-canvas.php';
    		
    	}
    	
    	return $template;
    	
    }
    
    // function to include the bbpress forum template file if needed
    function fse_bbp_theme_compat( $template ) {
    
    	if ( is_bbpress() ) {
    
    		// BBPress Style Pack Plugin Forums Index Template
    		if ( defined( 'BSP_PLUGIN_DIR' ) ) {
    
    			$template = BSP_PLUGIN_DIR . '/templates/bbpress.php';
    
    		} else {
    
    			// Default BBPress
    			// if current page is bbpress forum root page, load archive-forum to prevent double-listing of index
    			if ( isset( get_queried_object()->name ) ) {
    				if ( get_queried_object()->name == 'forum' ) {
    
    					$template = WP_CONTENT_DIR . '/plugins/bbpress/templates/default/extras/archive-forum.php';
    
    				}
    
    			// else, load page-front-forums or the rest of bbpress is broken with empty pages
    			} else {
    
    				$template = WP_CONTENT_DIR . '/plugins/bbpress/templates/default/extras/page-front-forums.php';
    
    			}
    			
    		}
    		
    	}
    	
    	return $template;
    
    }
    
    // main function for handling which theme file needs to be included
    if ( ! function_exists( 'fse_bbpress_support' ) ) {
    	function fse_bbpress_support() {
    		
    		// get current theme dir
    		$theme_dir = get_template_directory();
    
    		/* 
    		* Detect if FSE theme or traditional.
    		* FSE Block themes require a theme.json file.
    		* Use that to check instead of theme name or parent theme name.
    		* Perhaps a better method is available, but this works for now
    		*/ 		
    		if ( file_exists( $theme_dir . '/theme.json' ) ) {
    
    			// include wp-includes/template-canvas.php only if needed
    			if ( !basename( get_page_template() ) == 'template-canvas.php' ) {
    
    				add_filter( 'template_include', 'fse_bbpress_template' );
    
    			}
    
    			// include either the BSP template, or default BBPress template
    			add_filter ( 'bbp_template_include_theme_compat', 'fse_bbp_theme_compat' );
    
    		}
    	
    	}
    }
    add_action( 'after_setup_theme', 'fse_bbpress_support' );
    

    One issue with EVERY default BBPress template is that the header/footer/sidebar are trying to be pulled from template files that don’t exist in block themes. They’re being included, but don’t look right. I’m not sure of the best solution for that, other than to use the BBPress Style Pack Plugin which takes care of that and looks great.

    #232235
    Robin W
    Moderator

    ‘Associated Courses and Groups’ has nothing to do with bbpress.

    I’d suspect it is either something in learndash, or something you have called a page in WP where the shiortcode is held, or a name you have given to something.

    #232234
    theriddler
    Participant

    Hello,

    I am using LearnDash in combination with bbpress and the integration addin. Now there appears a sentence “Associated Courses and Groups:” on the forum overview page, which I can’t translate. LearnDash support said it has something to do with the [bbp-forum-index] shortcode output.

    Could you help me translate this string?

    Best regards
    Rene

    #232208
    vvmdov
    Participant

    Hello, I am using BBpress(2.6.9) on my website(WordPress 6.0.3) with Divi theme(4.18.0). When using any widget/shortcode of BBpress, as well as when trying to search the Forum, the header section I created with Divi changes its shape on the next opened page, it looks completely different and messy – the section size decreases, the menu items are arranged at the bottom, the font colors change, the logo becomes huge.

    I contacted Divi support, but since they don’t even know what BBpress is, they didn’t know how to fix the problem and advised me to contact “BBpress customer support”:
    – “So it seems like the archive template in the plugin is not working in the same way as the standard single post. You can clarify with the developers what template they are using and how it can be changed to make it work in the same way as the single template, at least the general header and footer parts.”

    As desperate as I was, I didn’t want to pass without trying. What is the cause of this problem, how should I solve it? Has anyone experienced this problem or know of a solution?

    #232166
    codejp3
    Participant

    Using the clues in this topic, this is what I have working for ANY FSE Block theme with the wonderful style-pack plugin:

    
    function fse_bbpress_template( $template ) {
    	$template = ABSPATH . WPINC . '/template-canvas.php';
    	return $template;
    }
    
    function fse_bbp_theme_compat( $template ) {
    	$template= BSP_PLUGIN_DIR.'/templates/bbpress.php';
    	return $template;
    }
    
    if ( ! function_exists( 'fse_bbpress_support' ) ) {
    	function fse_bbpress_support() {
    		// gt current theme dir
    		$theme_dir = get_template_directory();
    
    		// Detect if FSE theme or traditional.
    		// FSE Block themes require a theme.json file.
    		// Use that to check instead of theme name or parent theme name.
    		// Perhaps a better method is available, but this works for now.
    		$fse_theme = false;
    		if ( file_exists( $theme_dir.'/theme.json' ) ) { $fse_theme = true; }
    		
    		if ( !$fse_theme ) { return; }
    		
    		// disabled because it doesn't seem to be needed, regardless of style pack 
    		// $bsp_style_settings_theme_support['twentytwentytwo_activate'] setting
    		// template-canvas.php seems to be included by default
    		
    		//add_filter( 'template_include', 'fse_bbpress_template' );
    		
    		add_filter ( 'bbp_template_include_theme_compat' , 'fse_bbp_theme_compat' );
    	
    	}
    	
    }
    add_action( 'after_setup_theme', 'fse_bbpress_support' );
    

    and this little helper function helped me figure out what template was getting loaded in the first place:

    
    function fse_bbpress_print_template() {
    	if ( is_bbpress() ) {
    		//echo at the bottom of the page visibly
    		echo get_page_template();
    		
    		// or echo the template silently as an HTML comment
    		// echo '<!-- ' . get_page_template() . ' -->';
    	}
    }
    // DISABLE THIS ACTION HOOK AS SOON AS POSSIBLE! DO NOT LEAVE IT ACTIVE WHEN DEBUGGING IS DONE!
    add_action( 'bbp_template_after_forums_loop', 'fse_bbpress_print_template' );
    

    I’ve tried this on a few different FSE Block themes, and BBPress is displaying properly, and the style tweaks from the wonderful Style-Pack plugin are being applied.

    Like I said, it’s working regardless of the $bsp_style_settings_theme_support[‘twentytwentytwo_activate’] setting within the BSP plugin, but it uses the template from the plugin so it would still need to be installed an active, even without any styling tweaks applied.

    It’s not a permanent solution, but perhaps aspects of this could be applied to the BSP plugin, or your own custom solution.

    #232142
    Robin W
    Moderator

    I presume you have ‘anyone can register’ ticked in :

    dashboard>settings>general>membership – that will let anyone join, and at that stage you cannot know if they are real or not, so no automatic way to prevent.

    I’d suggest you move to a closed registration, so that you can manually join people.

    as for getting rid of those in there – you would need some code which would look for all users who have not made a forum post, but this might delete genuine users, so without a forumla to work out who is real or not, it would be hard to code/

    #232133
    Robin W
    Moderator

    you could add this to change the wording

    function change_translate_text( $translated_text ) {
    	if ( $translated_text == 'You cannot reply to this topic.' ) {
    	//set limit
    	$limit = 5 ;
    	//get replies for today
    	$user_id = get_current_user_id() ;
    	$reply=bbp_get_reply_post_type() ;
    	$today = getdate();
    	$args = array(
    		'post_type'=> $reply,
    		'order'    => 'ASC',
    		'orderby' => 'ID',
    		'post_status' => 'publish',
    		'posts_per_page' => -1,
    		'post_author' => $user_id,
    		'date_query' => array(
    		array(
    			'year'  => $today['year'],
    			'month' => $today['mon'],
    			'day'   => $today['mday'],
    		),
    		),
    		
    		);              
    
    	$the_query = new WP_Query( $args );
    	$count = $the_query->found_posts;
    	if ($count>=$limit) $translated_text = 'You have exceeded the number of replies you can post in a day' ;
    	}
    	return $translated_text;
    }
    add_filter( 'gettext', 'change_translate_text', 20 );
    #232132
    Robin W
    Moderator

    Just written this – should work

    add_filter ('bbp_current_user_can_access_create_reply_form' , 'rew_limit_replies') ;
    
    function rew_limit_replies ($retval) {
    	//set limit
    	$limit = 5 ;
    	//get replies for today
    	$user_id = get_current_user_id() ;
    	$reply=bbp_get_reply_post_type() ;
    	$today = getdate();
    	$args = array(
    		'post_type'=> $reply,
    		'order'    => 'ASC',
    		'orderby' => 'ID',
    		'post_status' => 'publish',
    		'posts_per_page' => -1,
    		'post_author' => $user_id,
    		'date_query' => array(
    		array(
    			'year'  => $today['year'],
    			'month' => $today['mon'],
    			'day'   => $today['mday'],
    		),
    		),
    		
    		);              
    
    	$the_query = new WP_Query( $args );
    	$count = $the_query->found_posts;
    	if ($count>=$limit) $retval = 0 ;
    return $retval ;
    }

    Just amend the line ‘$limit = 5 ;’ to whatever number you want

    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

    #232086
    wujackwu
    Participant

    Based on my recent trouble-shooting, your issue could be caused by two potential reasons:

    1. Your CDN service provider altered the link to your video file. You might want try turning it off, so that the address of your video would change back to something like https://yourdomain.com/wp-content/uploads/2022/10/cute_dog.mp4?time=1664812918, which is the actual location of your file. You may also check the source code of our pole line hardware website, on which we encountered a similar issue a few months ago. (We bought Godaddy’s WP plan, and its default CDN setting was turned on. We now use Cloudflare. A much better CDN. )
    2. Or, it may be caused by conflicting plugins installed on your website. Which means the embed function cannot work properly. You could try disable them all and flush your server cache to find the culprit.

    Personally, if you are code-savvy, I would recommend employing a method called lite youtube embed for videos. Simply put, it reduces page loading time by serving your video only after the viewer hit PLAY, which drastically reduces the amount of data transferred on page load.

    That’s all I can come up with based on your information. Best of luck!!

    #232083

    In reply to: Forum has blank pages

    Robin W
    Moderator

    ok, if this is a block theme then come back, otherwise take a look at

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

    section 8 and look at this link which gives a template

    https://codex.bbpress.org/theme-compatibility/getting-started-in-modifying-the-main-bbpress-template/

    #232077
    Robin W
    Moderator

    or you could just display the bbpress breadcrumb by by changing the css file, or putting this in the custom css

    .bbp-breadcrumb {
    	display: block !important;
    	padding-top: 20px;
    }
    #232076
    Robin W
    Moderator

    your theme is hiding the bbpress breadcrumbs in

    https://renaloo.com/wp-content/themes/digiqole-child/assets/css/custom.css line 2281

    This function will add a reference to the breadcrumb

    add_action ('bbp_template_before_single_topic' , 'rew_forum') ;
    
    function rew_forum () {
    	echo '<div class="rew_forum">' ;
    	$topic_id = bbp_get_reply_topic_id() ;
    	$forum_id = bbp_get_topic_forum_id() ;
    	echo '<a href="' . esc_url( bbp_get_forum_permalink( $forum_id ) ) . '" class="bbp-breadcrumb-forum">' . bbp_get_forum_title( $forum_id ).'</a>' ;
    	echo '</div>' ;
    }

    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

    #232055
    seangowans
    Participant

    Im using BBpress Version 2.6.9 and WordPress version: 5.9.3 and i’m working on my localhost.
    I have followed the documentation (method 2) and I keep ending up with the same issue. The Forum page has the [bbp-forum-index] shortcode which works fine, but when I click on the forum I created it returns a blank page.

    URL structure that returns blank page:
    mysite/forums/forum/test-forum/

    I have removed every plugin except BBPress and tested this on the 2022 WordPress theme and still no luck, any advice you could give me would be greatly appreciated.

    #232052

    In reply to: Order of search result

    quigli
    Participant

    Hello,
    yep, i have access to the code, children-theme installed (‘excellent’)
    Bye, Rainer

    #232038

    In reply to: Order of search result

    samsanatco
    Participant

    Hello
    Can you change the theme codes yourself?

    #232018
    erossini
    Participant

    I have an issue with bbPress. In the settings, I checked under /options-general.php?page=bbpress the option Auto-embed links.

    When I upload a video in the forum, the result is the link to the video instead of a player to play the video.

    How can I fix it?

Viewing 25 results - 951 through 975 (of 32,431 total)
Skip to toolbar