Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 1,451 through 1,475 (of 32,481 total)
  • Author
    Search Results
  • #223536

    In reply to: Forum Display

    Robin W
    Moderator

    create 2 categories and make your forums subs of these, create 2 pages and use a shortcode in each

    [bbp-topic-form forum_id=$forum_id] where $forum_id is the category

    #223513
    qlqlo
    Participant

    After I Install and activate bbPress nothing shows up in my admin area sidebar (Forum, Topics, Replies do not appear). When I create a new page and paste there a shortcode for displaying the whole forum index, the page shows an error. I don’t know what went wrong, I tested on my localhost and it worked fine.
    I also tried to delete the plugin and install it again.

    #223511
    regnalf
    Participant

    as no one answer this, i tried it by myself. i found a function in bbp-style-pack plugin for that.

    if (function_exists('bsp_is_forum_unread_amount'))
    {
    	
    	add_shortcode( 'bbp_count_new', 'bbpress_count_new' );
    	function bbpress_count_new( $atts )
    	{
    		
    		$output = "";
    		$count_new = 0;
    		
    
    		$query_foren = new WP_Query(array( 'post_type' => 'forum' ));
    		
    		
    		while($query_foren->have_posts())
    		{
    			$query_foren->the_post();
    			
    			$post_id = get_the_id();
    			
    			$bbp_forum_privategroups = get_post_meta( $post_id, '_private_group');			
    			$bbp_user_privategroups = preg_split('/\*/', get_user_meta (get_current_user_id(), 'private_group', true), -1, PREG_SPLIT_NO_EMPTY);
    			
    			if ( count( $bbp_forum_privategroups ) == 0 )
    			{
    				$amount_unr = bsp_is_forum_unread_amount( $post_id );
    				$count_new += $amount_unr->amount;
    			}
    			else
    			{
    				if ( count( array_intersect( $bbp_forum_privategroups, $bbp_user_privategroups )) > 0 )
    				{
    					$amount_unr = bsp_is_forum_unread_amount( $post_id );
    					$count_new += $amount_unr->amount;
    				}
    			}
    		}
    		
    		if ($count_new > 0 )
    		{
    			ob_start();
    			?><span style="margin-left: 0.3rem; font-size: 0.8rem; padding: 0.4rem;"> <?php echo($count_new); ?></span><?php
    			$output = ob_get_contents();
    			ob_end_clean();
    		}
    		
    		return $output;
    	}
    
    	
    }

    i hope i didn’t oversee something, because it is also combined with private forum groups!

    huetherb
    Participant

    I suppose this isn’t WordPress or BBPress specific, but trying to figure out if there is a WordPress way of doing this.

    I am using BBPress, and on some page, such as https://somesite.com/lesson/some-lesson/, I have a block with a link to a discussion topic. That link is of form

    <a href="javascript:void(0);" data-target="#myModal" data-href="somesite.com/forums/topic/required-discussion-1/" data-toggle="modal" class="openPopup"><h3 class="topictype-title">required discussion 1</h3></a>

    The modal popup is handled in bootstrap via

    
    <div class="modal fade" id="myModal" role="dialog">
       <div class="modal-dialog modal-xl">
          <div class="modal-content">
             <div class="modal-header"><button type="button" class="close" data-dismiss="modal">×</button><h4 class="modal-title">Class Discussion</h4>
             </div>
             <div class="modal-body"></div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
          </div>
       </div>
    </div>
    

    And with jQuery

    
        $('body').on('click', '[data-toggle="modal"]', function(){
            $($(this).data("target")+' .modal-body').load($(this).data("href"));
        });
    

    What happens now, is after hitting submit, the modal goes away, and the forum topic page with the submitted reply is loaded: url https://somesite.com/forums/topic/required-discussion-1/#post-25847

    The thing is, after user submits from the modal, I want either

    **1) the refresh (so, going to https://somesite.com/forums/topic/required-discussion-1/#post-25847) to happen in the modal, or**

    **2) for the modal to simply close and user is returned to exactly as they were prior to modal popping up, that is, to https://somesite.com/lesson/some-lesson/**

    Ideas on how to ideally achieve these two behaviors? I have never worked with modals before, so curious what are some best practices here to get the desired behavior.

    Thanks!

    #223501
    Robin W
    Moderator

    ok, that’s development rather than support.

    so you will need to alter templates and put these in your child theme.

    look for

    \templates\default\bbpress\loop-topics.php
    does topic list headers
    
    calls loop-single-topic
    \templates\default\bbpress\loop-single-topic.php
    lists each topic in the forum, last post and freshness
    
    lists topic content

    so for each find the file

    transfer this to your pc and edit

    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

    bbPress will now use this template instead of the original

    #223488
    regnalf
    Participant

    I know there is a widget to show somewhere on the page if there is new activity in the forums. But is there a possibility (maybe a shortcode?) to show only an icon when there is new activity in any forum? Or better yet an info with the number of new posts?

    #223481
    dalton125
    Participant

    I’ve been searching for a way to return the titles and links of every topic on my forum. I’m familiar with HTML and CSS, but a PHP novice, which I think is my downfall here.

    I found a call to

    <?php the_content();?>

    which seems to be generating the big grey box with a list of all the topics (image link: https://imgur.com/a/fKamtGH)

    However, I just want to return the topic titles and links to each topic, not the entire box. I can’t seem to find / write a PHP method that does this, does anyone have any advice?

    #223475
    Robin W
    Moderator
    #223472
    Morphim
    Participant

    Hi there

    It’s the end of Sept 2021 and I’ve been trying to sort out an old PHPBB conversion to BBPress.
    WP: 5.8.1 and BBPress 2.6.6

    I can confirm I’ve done this seemingly successfully. It took a few tries but with this thread I’ve got it working.

    I just wanted to share what worked in 2021.

    1. I exported my old PHPBB database (.sql file) and then set up a new database on my current host and imported the PHPBB to it.
    This just simplified any server timeouts and other connection issues.

    2. I obviously had BBpress installed within WP, but the included PHPBB converter doesn’t work (why??) so copied two files from this thread.

    a. Firstly, I had the ‘annonymous user’ loop mentioned above so copied @davidmanch great code (a couple of comments above) into:
    /wp-content/plugins/bbpress/includes/admin/classes/class-bbp-converter.php
    This fixed the never ending loop but the built in converter didn’t import any users, so …

    b. I copied @a8bit excellent code (3 posts above this one) into:
    /wp-content/plugins/bbpress/includes/admin/converters/phpbb.php
    This added many more steps to the import which completed without errors. I’m thinking this code might also have fixed the annonymous user loop too but didn’t try it on it’s own?? I’d already change the code in a. above. If you do this, maybe just try this code only and see if it works.

    So, if you find this now, it does work (for me at least) so hopefully you don’t have to hunt around for solutions.

    The BBPress guys need to look at these two pieces of code and see why their packaged converter doesn’t work. It’s very frustrating and shouldn’t be left to users much smarter than me to fix … but I’m glad they did.

    Cheers

    #223461

    Topic: Force Login

    in forum Installation
    msAniElle
    Participant

    I have tried looking through this forum to find what I need, and I just can’t seem to do so.

    I am by no means a coder, but I said I would help a friend put together a forum, and I would like everyone who clicks on the “forum” access button at the top of the page to be forced to log in if they are not already logged in. I would then like them to see the main forum page, not the dashboard unless they have higher clearance than participants.

    How does one do that? I saw someone post about the Private groups plugin… but will it do what I want it to do?

    #223381
    severbronny
    Participant

    I’m a newbie with code and web implementation, so forgive me if this is a dumb question. My readers have reported the following: “I’ve been trying to be able to post on your forum. I have a wordpress account, which I use to try to log in. After that it takes me to a jetpack and wordpress site, which Makes me put in my info again. But when I do, it then it takes me back to the original jetpack/wordpress page.”

    Here is the forum:

    Forum *new*

    And yet they can make comments on my site with ease:

    Discussion

    I installed bbPress using this slug: [bbp-forum-index]

    What am I missing? Thanks ahead!

    outkax
    Participant

    Thanks for your answer I have corrected my code with yours 🙂

    Robin W
    Moderator

    your triple === means that is has to match type (eg string or integer) as well as value, hence why

    if(bbp_forum_id() === '513')

    didn’t work, as the forum id is an integer and by havng quotes round the number you are asking it to be a string

    in your solution

    <?php if(bbp_get_forum_id() === $forum_id = 513): ?>

    would be better as

    <?php if(bbp_get_forum_id() === 513): ?>

    or better still

    <?php if(bbp_get_forum_id() == 513): ?>

    as unless you are using the $forum_id variable elsewhere (when it probbaly needs to be declared as a global) then the $forum_id = is redundant

    but glad you fixed it

    outkax
    Participant

    I think I found the solution 🙂 :

    <?php
    
    /**
     * Single Forum Content Part
     *
     * @package bbPress
     * @subpackage Theme
     */
    
    // Exit if accessed directly
    defined( 'ABSPATH' ) || exit;
    
    ?>
    
    <div id="bbpress-forums" class="bbpress-wrapper">
    
    	<?php bbp_breadcrumb(); ?>
    
    	<?php //bbp_forum_subscription_link(); ?>
    
    	<?php do_action( 'bbp_template_before_single_forum' ); ?>
    
    	<?php if ( post_password_required() ) : ?>
    
    		<?php bbp_get_template_part( 'form', 'protected' ); ?>
    
    	<?php else : ?>
    
    		<?php //bbp_single_forum_description(); ?>
    
    		<?php if ( bbp_has_forums() ) : ?>
    
    			<?php bbp_get_template_part( 'loop', 'forums' ); ?>
    
    		<?php endif; ?>
    
    		<?php if ( ! bbp_is_forum_category() && bbp_has_topics() ) : ?>
    
    			<?php bbp_get_template_part( 'pagination', 'topics'    ); ?>
    
    			<?php bbp_get_template_part( 'loop',       'topics'    ); ?>
    
    			<?php bbp_get_template_part( 'pagination', 'topics'    ); ?>
    
    			<?php bbp_get_template_part( 'form',       'topic'     ); ?>
    
    		<?php elseif ( ! bbp_is_forum_category() ) : ?>
    			<?php if(bbp_get_forum_id() === $forum_id = 513): ?>
    
    				<?php bbp_get_template_part( 'rules' ); ?>
    
    			<?php else :  ?>
    				<?php bbp_get_template_part( 'feedback',   'no-topics' ); ?>
    
    				<?php bbp_get_template_part( 'form',       'topic'     ); ?>
    			<?php ?>
    			<?php endif; ?>
    		<?php endif; ?>
    
    	<?php endif; ?>
    
    	<?php do_action( 'bbp_template_after_single_forum' ); ?>
    
    </div>
    
    Robin W
    Moderator

    sorry, untested code, go with

    if ($forum_id == ‘12345’) {

    outkax
    Participant

    I tried another method but no way bbp_forum_id only displays the forum id.I tried with I tried with “bbp_get_forum_id” that doesn’t work either.

    <div id="bbpress-forums" class="bbpress-wrapper">
    
    	<?php bbp_breadcrumb(); ?>
    
    	<?php //bbp_forum_subscription_link(); ?>
    
    	<?php do_action( 'bbp_template_before_single_forum' ); ?>
    
    	<?php if ( post_password_required() ) : ?>
    
    		<?php bbp_get_template_part( 'form', 'protected' ); ?>
    
    	<?php else : ?>
    
    		<?php //bbp_single_forum_description(); ?>
    
    		<?php if ( bbp_has_forums() ) : ?>
    
    			<?php bbp_get_template_part( 'loop', 'forums' ); ?>
    
    		<?php endif; ?>
    
    		<?php if ( ! bbp_is_forum_category() && bbp_has_topics() ) : ?>
    
    			<?php bbp_get_template_part( 'pagination', 'topics'    ); ?>
    
    			<?php bbp_get_template_part( 'loop',       'topics'    ); ?>
    
    			<?php bbp_get_template_part( 'pagination', 'topics'    ); ?>
    
    			<?php bbp_get_template_part( 'form',       'topic'     ); ?>
    
    		<?php elseif ( ! bbp_is_forum_category() ) : ?>
    			<?php if(bbp_forum_id() === '513'): ?>
    			<?php echo 'yes'; ?>
    			<?php else :  ?>
    				<?php bbp_get_template_part( 'feedback',   'no-topics' ); ?>
    
    				<?php bbp_get_template_part( 'form',       'topic'     ); ?>
    			<?php ?>
    			<?php endif; ?>
    		<?php endif; ?>
    
    	<?php endif; ?>
    
    	<?php do_action( 'bbp_template_after_single_forum' ); ?>
    
    </div>
    outkax
    Participant

    I tested with your code Robin, it does not work. The if is missing parentheses. But even with that doesn’t work. It displays all the forums with the content of the if and does not take into account the id I give it.

    #223269
    bobdobbs
    Participant

    I have a solution.

    It relies on a couple of assumptions: one being that the structure of URL’s is like this:
    http://mysite.com/forums/…&#8217;

    Assumption 2: all users with an account on the website are allowed to access the forum.

    This function does the following:
    If the user requests a resource under ‘/forums/’ then we test to see if the user has a wordpress account and is logged in. If the user isn’t logged into the wordpress account, then they get denied.

    In production I’ve replaced ‘wp_die’ with a wp_redirect to another page.

    /**
    * If a user is not a forum member, and requests the forum index page then redirect them
    */

    add_action('init', 'as_protect_forums');
    
    function  as_protect_forums() {
    
        // get the path of the requested URI
        $current_url = home_url($_SERVER['REQUEST_URI']);
    
        $path = parse_url($current_url, PHP_URL_PATH) ;
    
        $parts = explode('/', $path) ;
    
        $first_part = $parts[1] ;
    
        if (  $first_part === 'forums' ) {
            if ( 0 === get_current_user_id() ) {
                wp_die('nope');
            }
        }
    
    }
    
    

    Hi @outkax 👋

    The functionality you’re looking for does not currently exist.

    The bbp_get_template_part filter exists to hook into this API and extend the template parts to attempt to locate, so it would be achievable with some custom code.

    #223266
    Robin W
    Moderator

    have you been to

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

    and looked at item 3?

    #223263
    drivinghome
    Participant

    WP 5.8.1 bbPress 2.6.6

    Can the bbPress Forum 2.6.6 version be used with Elementor and or does it have a shortcode so that we can embed the forum onto an existing page.

    Thanks

    Greg

    Robin W
    Moderator

    I am very unclear as to what you are trying to achieve.

    if you want one forum say forum id 12345 to display differently, then just amend content-single-forum to

    <?php
    $forum_id = bbp_forum_id() ; 
    if $forum_id = '12345' {
    ?>
    
    <div id="bbpress-forums" class="bbpress-wrapper">
    
    	<?php bbp_breadcrumb(); ?>
    
    	<?php bbp_forum_subscription_link(); ?>
    
    	<?php do_action( 'bbp_template_before_single_forum' ); ?>
    
    	<?php if ( post_password_required() ) : ?>
    
    		<?php bbp_get_template_part( 'form', 'protected' ); ?>
    
    	<?php else : ?>
    
    		<?php bbp_single_forum_description(); ?>
    
    		<?php if ( bbp_has_forums() ) : ?>
    
    			<?php bbp_get_template_part( 'loop', 'forums' ); ?>
    
    		<?php endif; ?>
    
    		<?php if ( ! bbp_is_forum_category() && bbp_has_topics() ) : ?>
    
    			<?php bbp_get_template_part( 'pagination', 'topics'    ); ?>
    
    			<?php bbp_get_template_part( 'loop',       'topics'    ); ?>
    
    			<?php bbp_get_template_part( 'pagination', 'topics'    ); ?>
    
    			<?php bbp_get_template_part( 'form',       'topic'     ); ?>
    
    		<?php elseif ( ! bbp_is_forum_category() ) : ?>
    
    			<?php bbp_get_template_part( 'feedback',   'no-topics' ); ?>
    
    			<?php bbp_get_template_part( 'form',       'topic'     ); ?>
    
    		<?php endif; ?>
    
    	<?php endif; ?>
    
    	<?php do_action( 'bbp_template_after_single_forum' ); ?>
    
    </div>
    <?php
    }
    else {
    ?>
    <div id="bbpress-forums" class="bbpress-wrapper">
    
    	<?php bbp_breadcrumb(); ?>
    
    	<?php bbp_forum_subscription_link(); ?>
    
    	<?php do_action( 'bbp_template_before_single_forum' ); ?>
    
    	<?php if ( post_password_required() ) : ?>
    
    		<?php bbp_get_template_part( 'form', 'protected' ); ?>
    
    	<?php else : ?>
    
    		<?php bbp_single_forum_description(); ?>
    
    		<?php if ( bbp_has_forums() ) : ?>
    
    			<?php bbp_get_template_part( 'loop', 'forums' ); ?>
    
    		<?php endif; ?>
    
    		<?php if ( ! bbp_is_forum_category() && bbp_has_topics() ) : ?>
    
    			<?php bbp_get_template_part( 'pagination', 'topics'    ); ?>
    
    			<?php bbp_get_template_part( 'loop',       'topics'    ); ?>
    
    			<?php bbp_get_template_part( 'pagination', 'topics'    ); ?>
    
    			<?php bbp_get_template_part( 'form',       'topic'     ); ?>
    
    		<?php elseif ( ! bbp_is_forum_category() ) : ?>
    
    			<?php bbp_get_template_part( 'feedback',   'no-topics' ); ?>
    
    			<?php bbp_get_template_part( 'form',       'topic'     ); ?>
    
    		<?php endif; ?>
    
    	<?php endif; ?>
    
    	<?php do_action( 'bbp_template_after_single_forum' ); ?>
    
    </div>
    <?php } ?>

    and change whichever display you want

    #223247

    In reply to: Topic Sidebar

    Robin W
    Moderator

    you could try method 2 in this

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

    it might work, it might not 🙂

    #223218
    Ludovic S. Clain
    Participant

    Hi there 👋
    I followed this step by step guide
    👉 https://codex.bbpress.org/step-by-step-guide-to-setting-up-a-bbpress-forum/#3-%c2%a0creating-a-forum-page

    And I’m annoyed with one quirk that I can’t seem to resolve: My borders aren’t showing!
    With method # 1 my borders disappear and with method # 2 everything is normal.
    How can I fix this please?

    Screenshot display forums list issue

    My regards,
    Ludovic

    #223208
    Nigel M Rodgers
    Participant

    Hi,

    I just did something similar for Rank Math SEO plugin:

    
    
    /**
     * Sets bbPress user profile pages to noindex
     *
     * @param array $robots The meta robots directives.
     */
    add_filter( 'rank_math/frontend/robots', function( $robots ) {
        
        if (!bbp_is_single_user_profile()) {
            return $robots;
            }
        unset( $robots['index']);
        $robots['noindex'] = 'noindex';
        return $robots;
    });
    

    Cheers

Viewing 25 results - 1,451 through 1,475 (of 32,481 total)
Skip to toolbar