Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 9,926 through 9,950 (of 32,519 total)
  • Author
    Search Results
  • #155909
    melanie bund
    Participant

    Hi my forum appears in a part of the site that has a generic login. So what i need is that users have to type in email and name in order to post – is this possible? is there a shortcode for this or do i have to add something to the bbpress.php?
    thank you in advance
    Melanie

    #155896
    Bob1nz
    Participant

    I found this

    /**
     * Return a map of WordPress roles to bbPress roles. Used to automatically grant
     * appropriate bbPress roles to WordPress users that wouldn't already have a
     * role in the forums. Also guarantees WordPress admins get the Keymaster role.
     *
     * @since bbPress (r4334)
     *
     * @return array Filtered array of WordPress roles to bbPress roles
     */
    function bbp_get_user_role_map() {
    
    	// Get the default role once here
    	$default_role = bbp_get_default_role();
    
    	// Return filtered results, forcing admins to keymasters.
    	return (array) apply_filters( 'bbp_get_user_role_map', array (
    		'administrator' => bbp_get_keymaster_role(),
    		'editor'        => $default_role,
    		'author'        => $default_role,
    		'contributor'   => $default_role,
    		'subscriber'    => $default_role
    	) );
    }

    Is there any way to add extra roles in that without editing the plugin files directly?

    #155894
    Robin W
    Moderator

    ok, the software is held in files, the content (forums, topics etc) is held in the database.

    Please read

    https://codex.bbpress.org/creating-a-test-site/

    for a long explanation of how wordpress is structured.

    I believe you issue is as simple as that the level of user that you are does not permit you to se the ‘backend’ – that is the forum stuff in the dashboard – so deleting and recreating the plugin will not help you.

    The answer I think is to go into phpmyadmin, and edit your entry to give yourself permission as per previous answer.

    The link above should give you sufficient to be able to find your entry and edit it.

    #155869
    Bob1nz
    Participant

    Hi ๐Ÿ™‚

    Well I am setting up a small community for a minecraft server and we have a plugin for minecraft that will sync the ranks in game to the website http://www.spigotmc.org/resources/communitybridge.2232/

    So I am trying to replicate the ranks in game on the wordpress website.

    The end goal is
    InGameRank -> WordPressRole -> bbPressRole
    Owner -> Owner -> Owner
    Co-Owner -> Co-Owner -> Co-Owner
    Admin -> Admin -> Admin
    Moderator -> Moderator -> Moderator
    Member -> Member -> Member
    Guest -> Guest -> Guest

    The owner would essentially be bbPress’s keymaster but I would like to define the capabilities of each role.

    Using the code I posted I am unable to change my forum role.
    I am currently still set as Administrator in the Site Role.
    When I select my user in the dashboard and select change the forum role to the owner rank I created and click change it just reloads the page and my forum role is still keymaster.
    I am able to change other users forum roles correctly.

    My main question is how to get the wordpress roles to sync to the bbPress roles effectively making it so if i change the wordpress role the bbpress role will also change.

    (what is up with the tag changes I did not put those)

    #155867
    Robin W
    Moderator

    @skisma

    The shortcodes can be used on any wordpress page

    so if fro instance you wanted a menu item that display the most recent 15 topics across all your forums, so that when people selected this menu item that what they saw, then you would

    1. create a page – maybe called ‘latest topics’
    2. put the shortcode into the content section in this case

    [bbp-topic-index]
    

    3. add that page to the menu

    #155864
    Robin W
    Moderator

    Thanks for posting the code, which if needed I’ll delve into

    but firstly

    It doesnโ€™t appear to be working as intended though as I cannot give myself the owner role
    

    Can you give a bit more detail here as to exactly what you are doing, and where what you expect to happen isn’t, and any error messages etc.

    That is fully explain what ‘I cannot give myself’ means

    Thanks

    #155861
    Robin W
    Moderator

    I think you mean breadcrumbs the following shows breadcrumbs

    Layout and functionality – Examples you can use

    They are still there, so you should see them, might be another plugin or your theme is hiding them

    try

    Plugins

    Deactivate all but bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.

    Themes

    If plugins don’t pinpoint the problem, as a test switch to a default theme such as twentytwelve, and see if this fixes.

    #155848
    Hephaestus_Xii
    Participant

    Just in case it is not understood what i am looking to do. I want to be able to distinguish each forum as categories for example

    General discussions forum ————— Topics —————–Posts

    Topic 1
    Topic 2

    Funny Video Forum ———————— Topics ——————— Posts

    Topic 1
    Topic 2

    And so on …. so that it is broken into sections. I have made the forums and used the shortcode to display the forums.

    #155847
    Ellievant
    Participant

    Hey there,
    after having recently started with bbpress 2.5.4 and WP 4.1, I ran into a “404” problem after having created forum and topic as per the step-by-step directive (using method #2 with shortcode).
    Right from the start, a “404” appeared when startgin from the forum index page (the one with the shortcode). I spent the last 40 hrs reading and trying the various proposed fixes, none worked.
    However, deactivating the installed plugins and trying did point to WooCommerce Multilingual
    being the culprit, since the forums, subforums, categories, topics work fine when WC Mutlilingual is deactivated. If WC ML is activated, the same URL (using “postname”) is crashing to a “404”.

    I somebody has run into similar problem and/or a diagnosis on what the reason is-
    or even better can provide the magic fix, please step up and collect the praise… I myself m at the very end of my wits and carry a dangerous 1/8 knowledge about what I am doing…

    Cheers,
    O.

    #155845
    Robin W
    Moderator

    To change it in the database, you need to

    find out the id of the user – you can look that up in the ‘users’ table – probably called ‘wp_users’, just look for a line with the username in, and the user_id will be in the ID column.

    Then in the usermeta table sort by user_id, and look for your user, then the entry called

    wp_capabilities

    For a keymaster and admin it needs to say

    a:2:{s:13:"administrator";s:1:"1";s:13:"bbp_keymaster";b:1;}

    so FIRST copy what is already in there and save it to notepad or somewhere safe – you’ll want to be able to change it back if it doesn’t work and locks you out !!

    Then edit and put the above in.

    #155844
    Bob1nz
    Participant

    Hi

    This is my third time trying to post here hopefully it sticks this time.

    I am trying to add some custom roles to the bbpress forums and I have followed the Custom Capabilities codex page.

    It doesn’t appear to be working as intended though as I cannot give myself the owner role

    I would like these roles in bbpress to sync with some custom wp roles made with the members plugin.

    sorry for the wall of text below but its an effort to get this topic posted (i had links in the previous topics)

    here is what i have in my child themes functions.php

    // add bbPress Roles********************************************
    
     
    function add_new_roles( $bbp_roles )
    {
        /* Add a role called BlockFusion Owner */
        $bbp_roles['bbp_owner'] = array(
            'name' => 'BlockFusion Owner',
            'capabilities' => custom_capabilities( 'bbp_owner' )
            );
     
        /* Add a role called Co-Owner */
        $bbp_roles['bbp_co_owner'] = array(
            'name' => 'Co-Owner',
            'capabilities' => custom_capabilities( 'bbp_co_owner' )
            );
     
        /* Add a role called Admin */
        $bbp_roles['bbp_admin'] = array(
            'name' => 'Admin',
            'capabilities' => custom_capabilities( 'bbp_admin' )
            );
     
        /* Add a role called Moderator */
        $bbp_roles['bbp_moderator'] = array(
            'name' => 'Moderator',
            'capabilities' => custom_capabilities( 'bbp_moderator' )
            );
     
        /* Add a role called Member */
        $bbp_roles['bbp_member'] = array(
            'name' => 'Member',
            'capabilities' => custom_capabilities( 'bbp_member' )
            );
     
        /* Add a role called Guest */
        $bbp_roles['bbp_guest'] = array(
            'name' => 'Guest',
            'capabilities' => custom_capabilities( 'bbp_guest' )
            );
     
        return $bbp_roles;
    }
     
    add_filter( 'bbp_get_dynamic_roles', 'add_new_roles', 1 );
     
    function add_role_caps_filter( $caps, $role )
    {
        /* Only filter for roles we are interested in! */
        if( $role == 'bbp_owner' )
            $caps = custom_capabilities( $role );
     
        if( $role == 'bbp_co_owner' )
            $caps = custom_capabilities( $role );
     
        if( $role == 'bbp_admin' )
            $caps = custom_capabilities( $role );
     
        if( $role == 'bbp_moderator' )
            $caps = custom_capabilities( $role );
     
        if( $role == 'bbp_member' )
            $caps = custom_capabilities( $role );
     
        if( $role == 'bbp_guest' )
            $caps = custom_capabilities( $role );
     
        return $caps;
    }
     
    add_filter( 'bbp_get_caps_for_role', 'add_role_caps_filter', 10, 2 );
     
    function custom_capabilities( $role )
    {
        switch ( $role )
        {
     
            /* Capabilities for 'BlockFusion Owner' role */
            case 'bbp_owner':
                return array(
    
    				// Keymasters only
    				'keep_gate'             => true,
                    
                    // Primary caps
                    'spectate'              => true,
                    'participate'           => true,
                    'moderate'              => true,
                    'throttle'              => true,
                    'view_trash'            => true,
     
                    // Forum caps
                    'publish_forums'        => true,
                    'edit_forums'           => true,
                    'edit_others_forums'    => true,
                    'delete_forums'         => true,
                    'delete_others_forums'  => true,
                    'read_private_forums'   => true,
                    'read_hidden_forums'    => true,
     
                    // Topic caps
                    'publish_topics'        => true,
                    'edit_topics'           => true,
                    'edit_others_topics'    => true,
                    'delete_topics'         => true,
                    'delete_others_topics'  => true,
                    'read_private_topics'   => true,
     
                    // Reply caps
                    'publish_replies'       => true,
                    'edit_replies'          => true,
                    'edit_others_replies'   => true,
                    'delete_replies'        => true,
                    'delete_others_replies' => true,
                    'read_private_replies'  => true,
     
                    // Topic tag caps
                    'manage_topic_tags'     => true,
                    'edit_topic_tags'       => true,
                    'delete_topic_tags'     => true,
                    'assign_topic_tags'     => true,
                );
     
                /* Capabilities for 'Co-Owner' role */
            case 'bbp_co_owner':
                return array(
                    // Primary caps
                    'spectate'              => true,
                    'participate'           => true,
                    'moderate'              => true,
                    'throttle'              => true,
                    'view_trash'            => true,
     
                    // Forum caps
                    'publish_forums'        => true,
                    'edit_forums'           => true,
                    'edit_others_forums'    => true,
                    'delete_forums'         => true,
                    'delete_others_forums'  => true,
                    'read_private_forums'   => true,
                    'read_hidden_forums'    => true,
     
                    // Topic caps
                    'publish_topics'        => true,
                    'edit_topics'           => true,
                    'edit_others_topics'    => true,
                    'delete_topics'         => true,
                    'delete_others_topics'  => true,
                    'read_private_topics'   => true,
     
                    // Reply caps
                    'publish_replies'       => true,
                    'edit_replies'          => true,
                    'edit_others_replies'   => true,
                    'delete_replies'        => true,
                    'delete_others_replies' => true,
                    'read_private_replies'  => true,
     
                    // Topic tag caps
                    'manage_topic_tags'     => true,
                    'edit_topic_tags'       => true,
                    'delete_topic_tags'     => true,
                    'assign_topic_tags'     => true,
                );
     
                /* Capabilities for 'Admin' role */
            case 'bbp_admin':
                return array(
                    // Primary caps
                    'spectate'              => true,
                    'participate'           => true,
                    'moderate'              => true,
                    'throttle'              => true,
                    'view_trash'            => true,
     
                    // Forum caps
                    'publish_forums'        => false,
                    'edit_forums'           => false,
                    'edit_others_forums'    => false,
                    'delete_forums'         => false,
                    'delete_others_forums'  => false,
                    'read_private_forums'   => true,
                    'read_hidden_forums'    => true,
     
                    // Topic caps
                    'publish_topics'        => true,
                    'edit_topics'           => true,
                    'edit_others_topics'    => true,
                    'delete_topics'         => true,
                    'delete_others_topics'  => true,
                    'read_private_topics'   => true,
     
                    // Reply caps
                    'publish_replies'       => true,
                    'edit_replies'          => true,
                    'edit_others_replies'   => true,
                    'delete_replies'        => true,
                    'delete_others_replies' => true,
                    'read_private_replies'  => true,
     
                    // Topic tag caps
                    'manage_topic_tags'     => true,
                    'edit_topic_tags'       => true,
                    'delete_topic_tags'     => true,
                    'assign_topic_tags'     => true,
                );
     
                /* Capabilities for 'Moderator' role */
            case 'bbp_moderator':
                return array(
                    // Primary caps
                    'spectate'              => true,
                    'participate'           => true,
                    'moderate'              => true,
                    'throttle'              => true,
                    'view_trash'            => true,
     
                    // Forum caps
                    'publish_forums'        => false,
                    'edit_forums'           => false,
                    'edit_others_forums'    => false,
                    'delete_forums'         => false,
                    'delete_others_forums'  => false,
                    'read_private_forums'   => true,
                    'read_hidden_forums'    => true,
     
                    // Topic caps
                    'publish_topics'        => true,
                    'edit_topics'           => true,
                    'edit_others_topics'    => true,
                    'delete_topics'         => true,
                    'delete_others_topics'  => true,
                    'read_private_topics'   => true,
     
                    // Reply caps
                    'publish_replies'       => true,
                    'edit_replies'          => true,
                    'edit_others_replies'   => true,
                    'delete_replies'        => true,
                    'delete_others_replies' => true,
                    'read_private_replies'  => true,
     
                    // Topic tag caps
                    'manage_topic_tags'     => true,
                    'edit_topic_tags'       => true,
                    'delete_topic_tags'     => true,
                    'assign_topic_tags'     => true,
                );
     
                /* Capabilities for 'Member' role */
            case 'bbp_member':
                return array(
                    // Primary caps
                    'spectate'              => true,
                    'participate'           => true,
                    'moderate'              => false,
                    'throttle'              => true,
                    'view_trash'            => false,
     
                    // Forum caps
                    'publish_forums'        => false,
                    'edit_forums'           => false,
                    'edit_others_forums'    => false,
                    'delete_forums'         => false,
                    'delete_others_forums'  => false,
                    'read_private_forums'   => true,
                    'read_hidden_forums'    => false,
     
                    // Topic caps
                    'publish_topics'        => true,
                    'edit_topics'           => true,
                    'edit_others_topics'    => false,
                    'delete_topics'         => true,
                    'delete_others_topics'  => false,
                    'read_private_topics'   => true,
     
                    // Reply caps
                    'publish_replies'       => true,
                    'edit_replies'          => true,
                    'edit_others_replies'   => false,
                    'delete_replies'        => true,
                    'delete_others_replies' => false,
                    'read_private_replies'  => true,
     
                    // Topic tag caps
                    'manage_topic_tags'     => true,
                    'edit_topic_tags'       => true,
                    'delete_topic_tags'     => true,
                    'assign_topic_tags'     => true,
                );
     
                /* Capabilities for 'Guest' role */
            case 'bbp_guest':
                return array(
                    // Primary caps
                    'spectate'              => true,
                    'participate'           => true,
                    'moderate'              => false,
                    'throttle'              => true,
                    'view_trash'            => false,
     
                    // Forum caps
                    'publish_forums'        => false,
                    'edit_forums'           => false,
                    'edit_others_forums'    => false,
                    'delete_forums'         => false,
                    'delete_others_forums'  => false,
                    'read_private_forums'   => true,
                    'read_hidden_forums'    => false,
     
                    // Topic caps
                    'publish_topics'        => true,
                    'edit_topics'           => true,
                    'edit_others_topics'    => false,
                    'delete_topics'         => true,
                    'delete_others_topics'  => false,
                    'read_private_topics'   => true,
     
                    // Reply caps
                    'publish_replies'       => true,
                    'edit_replies'          => true,
                    'edit_others_replies'   => false,
                    'delete_replies'        => true,
                    'delete_others_replies' => false,
                    'read_private_replies'  => true,
     
                    // Topic tag caps
                    'manage_topic_tags'     => true,
                    'edit_topic_tags'       => true,
                    'delete_topic_tags'     => true,
                    'assign_topic_tags'     => true,
                );
     
                break;
     
            default :
                return $role;
        }
    }
    
    #155805

    In reply to: CSS issue

    Robkk
    Moderator

    try this

    add this code anywhere you can put custom css

    li.bbp-body div.hentry {
    margin-bottom: 0;
    overflow: hidden;
    padding: 0px !important;
    }
    Robkk
    Moderator

    the loop-forums.php file you downloaded from github

    and in the same file you can change word Freshness to whatever you want.

    just change this

    <li class="bbp-forum-freshness"><?php _e( 'Freshness', 'bbpress' ); ?></li>

    to something like this for example.

    <li class="bbp-forum-freshness"><?php _e( 'Last Post', 'bbpress' ); ?></li>

    #155789

    In reply to: Import Hung?

    Robkk
    Moderator

    we are not dead :/


    @netweb
    is the bbPress community’s import specialist

    the guy is most likely asleep now because he was working on some bbPress tickets all night… or all day depending on Aussie time??

    as for bbcodes bbcodes is not a default feature for bbPress you would need an additional plugin for that.

    https://wordpress.org/plugins/gd-bbpress-tools/ this plugin comes with a quote feature and more.

    there is another plugin called bbpress 2 bbcode which would also need the whitelist plugin by the same developer.

    Robkk
    Moderator

    well really your suppose to put bbPress plugin CSS in a folder called CSS in your child theme in a file called bbpress.css , more info here

    https://codex.bbpress.org/theme-compatibility/

    but adding the code to your child themes css file is fine
    jetpack’s custom css module is fine too.

    to remove the footer completely

    remove all this code in the file.

    <li class="bbp-footer">
    
    	<div class="tr">
    		<p class="td colspan4">&nbsp;</p>
    	</div><!-- .tr -->
    
    </li><!-- .bbp-footer -->
    j0n4h
    Participant

    @skisma Actually, unrelated, but would you mind telling me where the line of code is located to change “freshness”? I know there’s that plugin, but it seems excessive to use it to change one thing.

    #155786
    Skisma
    Participant

    Sorry to ask such a silly question, but I cannot seem to find info on them other than the http://codex.bbpress.org/shortcodes/ page. I have an idea of what they are, I’m just not sure how exactly to use them. It explains on that page that I just insert them into my desired page, but does not elaborate on that. I was hoping to find an article somewhere that goes over them in detail, but have yet to find it. So, I’ve decided to make a noob post here the bbpress forums.

    Robkk
    Moderator

    its no problem with the file

    its just that the footer is a different color than it should be

    this should make it look better

    #bbpress-forums li.bbp-footer {
    background: #383838;
    border-top: none;
    font-weight: bold;
    padding: 8px;
    text-align: center;
    }
    Skisma
    Participant

    @j0n4h

    Are you talking about the spacing between each group of forums? If so, this is how the code is written and it is part of the desired layout. I just recently used this same code and my forums look great! You can compare to yours and see if there’s a difference?

    http://forgehaven.com/forums/

    #155773
    Angelo Rocha
    Participant

    I need create a query to bring the list of forums and subforums on the homepage of my website, i woudn’t like to use shortcodes cuz i want create a custom style. I did a wp-query but i can’t use functions to show the topic, replies and posts quantity.

    <?php
    	$args = array(
    		'post_type' => 'forum',
    		'order' => 'DESC',
    		'orderby' => 'date'
    	);
    	$query = new WP_Query($args);
    ?>
    Foruns|
    Posts
    <?php if( $query -> have_posts() ): ?>
    	<?php while ($query -> have_posts() ) : $query -> the_post(); ?>
    		<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    			<?php the_title(); ?>
    		</a>
    		
    		<?php $value = bbp_get_forum_post_count(); echo $value; ?>
    		
    	<?php endwhile; ?>
    	
    	<?php wp_reset_postdata(); ?>
    	
    <?php else: ?>
    	Nothing yet...
    <?php endif; ?>

    Thanks for help.

    #155772
    Robkk
    Moderator

    add this to functions.php in your child theme

    /**
     * Include bbPress 'topic' custom post type in WordPress' search results
     */
    function ntwb_bbp_topic_cpt_search( $topic_search ) {
    	$topic_search['exclude_from_search'] = false;
    	return $topic_search;
    }
    add_filter( 'bbp_register_topic_post_type', 'ntwb_bbp_topic_cpt_search' );
    
    /**
     * Include bbPress 'reply' custom post type in WordPress' search results
     */
    function ntwb_bbp_reply_cpt_search( $reply_search ) {
    	$reply_search['exclude_from_search'] = false;
    	return $reply_search;
    }
    add_filter( 'bbp_register_reply_post_type', 'ntwb_bbp_reply_cpt_search' );

    got the code from here

    https://gist.github.com/ntwb/7363a1de1184d459f0c3

    #155768
    Angelo Rocha
    Participant

    Hi!
    How to make the bbpress content show in wordpress search? I create a custom search:

    <div class="col-md-8 col-md-offset-4 searchform-top" id="searchform-top">
    <form class="input-group" role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
        <input class="form-control input-block" id="appendedInputButton" type="text" placeholder="Buscar no site" name="s" id="s">
        <span class="input-group-btn">
            <button class="btn btn-primary" type="submit" id="searchsubmit">Buscar</button>
        </span>
    </form>
    </div>

    But bbpress results not appear when i search it.

    #155764

    In reply to: Remove Separator

    Robin W
    Moderator

    never write code whilst your other half is waiting to go out !

    ok, this works

    function remove_sep ($args) {
    $args['before'] = '' ;
    return $args ;
    }
    
    add_filter ('bbp_before_get_forum_subscribe_link_parse_args', 'remove_sep') ;
    

    On your larger point, there are a lot of resources, but it takes a lot of practice to get good at PHP, and to understand how any plugin works which is the size that bbpress is.

    Generally it is quicker to ask a question on here, than spend hours delving into bbpress. But if you start wanting to really tailor it, then the step by step guides and other documentation will try and get you into how to go about finding code within bbpress.

    I know nothing of php 18months ago (I’m just a humble bbpress user – I didn’t write any of it!), and now have several plugins for bbpress to add functionality, so it is quire do-able.

    I’ve tried to get much of my learning into the documentation, so have a look round

    Codex

    #155762
    derricksmith01
    Participant

    Hello,

    I really needed this feature so I dug into the code and came up with a solution that doesn’t modify core files. The solution hooks the query pre_get_posts and uses the buddypress ‘plugins’ template file to catch and display the group sub forums.

    This probably isn’t the most efficient solution but it seems to work in my environment. I’ll post back if I notice any issues as more subforums are created.

    Here are the functions – place in your theme’s functions.php. I also included my plugins.php file also.

    // functions.php

    
    //Filters bbpress forum permalink if on a group forum page.  Keeps users from being redirected to sitewide forums
    function buddyboss_forum_permalink($link){
    	global $wpdb, $bp;
    	if (strpos($link, "/forums/forum/")){
    
    			$forum = substr($link, strpos($link, "/forum/") + 7);   
    			$forums = explode("/",$forum);
    			$args=array(
    				'post_type' => 'forum',
    				'name' => $forums[0],
    			);
    			$root_forum = get_posts( $args );
    			$group_id = $wpdb->get_var(
    				" SELECT group_id
    				  FROM wp_bp_groups_groupmeta
    				  WHERE meta_key = 'forum_id' AND meta_value = '". serialize(array($root_forum[0]->ID)) ."'"
    			);
    			if (isset($group_id)){
    				$group = groups_get_group( array( 'group_id' => $group_id ) );
    				unset($forums[0]);
    				$forums = implode("/",$forums);
    				$permalink = bp_get_group_forum_permalink($group)."/".$forums;
    			} else {
    				$permalink = $link;
    			}
    			
    	}
    	return $permalink;
    }
    add_filter('bbp_get_forum_permalink','buddyboss_forum_permalink',10,1);
    
    //Filters bbpress topic permalink if on a group forum page.  Keeps users from being redirected to sitewide forums
    function buddyboss_topic_permalink($link){
    	global $wpdb, $bp;
    		if (strpos($link, "/forums/topic/")){
    			$start_topic = substr($link, strpos($link, "/topic/") + 7);   
    			
    			$args=array(
    				'post_type' => 'topic',
    				'name' => $start_topic,
    			);
    			$topic = get_posts( $args );
    			
    			$topic_forums = get_post_ancestors( $topic[0]->ID );
    
    			$root_forum_id = end($topic_forums);
    			$group_id = $wpdb->get_var(
    				" SELECT group_id
    				  FROM wp_bp_groups_groupmeta
    				  WHERE meta_key = 'forum_id' AND meta_value = '". serialize(array($root_forum_id)) ."'"
    			);
    			
    			if (isset($group_id)){
    				
    				$group = groups_get_group( array( 'group_id' => $group_id ) );
    				array_pop($topic_forums);  //Pop group's root forum
    				
    				foreach ($topic_forums as $forum){
    					$post = get_post($forum); 
    					$slug = $post->post_name;
    					$forum_parts .= $slug."/";
    				}
    				$permalink = bp_get_group_forum_permalink($group)."/".$forum_parts."topic/".$start_topic;
    			} else {
    				$permalink = $link;
    			}
    			
    		}	
    			
    	return $permalink;
    }
    add_filter('bbp_get_topic_permalink','buddyboss_topic_permalink',10,1);
    
    //Filters bbpress reply permalink if on a group forum page.  Keeps users from being redirected to sitewide forums
    function buddyboss_reply_permalink($link){
    	if (strpos($link, "/forums/reply/")){
    			$reply = str_replace(site_url()."/forums/reply/","reply/",$link);
    			$forum = str_replace("/forums/forum/".$bp->groups->current_group->slug, "/groups/".$bp->groups->current_group->slug ."/forum", bbp_get_topic_permalink(bbp_get_topic_id()));
    		$permalink = $forum.$reply;
    	}
    	return $link;
    }
    add_filter('bbp_get_reply_permalink','buddyboss_reply_permalink',10,1);
    
    function buddyboss_bbpress_pre_get_posts($query){
    	global $bp;
    
    	if( $query->is_main_query()) {
    		
    		if (bp_current_action() == 'forum'){
    		
    			if (!empty($bp->action_variables) && !in_array("topic", $bp->action_variables) && !in_array("reply", $bp->action_variables)){  //Sub Forum
    				$forum = end($bp->action_variables);
    				
    				$args = array(
    					'post_type' => 'forum',
    					'name' => $forum
    				);
    				$forums = get_posts( $args );	
    				$parent = $query->get('p');
    				$query->set('p','');
    				$query->set('post_parent',$parent);
    	
    				bbpress()->current_forum_id = $forums[0]->ID;
    				bbp_set_query_name( 'bbp_single_forum' );
    				
    				return $query;
    			} 
    			
    			if (empty($bp->action_variables) ) {  //Root Group Forum
    				bbp_set_query_name( 'bbp_single_forum' );
    				
    				return $query;
    				
    			}
    			
    			if (in_array("topic", $bp->action_variables) && !in_array("reply", $bp->action_variables)){  //Topic
    				$topic = end($bp->action_variables);
    				if ($topic == 'edit'){
    					$edit_key == array_search($topic,$bp->action_variables);
    					$topic = $bp->action_variables[$edit_key-1];
    				}
    				
    				$args = array(
    					'post_type' => 'topic',
    					'name' => $topic
    				);
    				$topics = get_posts( $args );	
    
    				$query->set('p','');
    				$query->set('post_parent',$topics[0]->post_parent);
    				
    				bbpress()->current_forum_id = $topics[0]->post_parent;
    				bbpress()->current_topic_id = $topics[0]->ID;
    				bbp_set_query_name( 'bbp_single_topic' );
    				if (end($bp->action_variables) == 'edit'){
    					bbpress()->current_view_id = 'edit';
    				}
    				
    				return $query;
    			}
    			
    			if (in_array("topic", $bp->action_variables) && in_array("reply", $bp->action_variables)){ //Reply
    				$reply = array_search('reply', $bp->action_variables);
    				$reply_id = $bp->action_variables[$reply+1];
    			
    				$reply_post = get_post( $reply_id );
    				$query->set('p',$reply_id);
    				
    				bbpress()->current_topic_id = $reply_post->post_parent;
    				bbpress()->current_reply_id = $reply_id;
    				bbp_set_query_name( 'bbp_single_reply' );
    				if (end($bp->action_variables) == 'edit'){
    					bbpress()->current_view_id = 'edit';
    				}
    				return $query;
    			}
    			
    		}
    	}
    	return $query;
    }
    add_action('pre_get_posts','buddyboss_bbpress_pre_get_posts',10, 1);
    
    function buddyboss_bbpress_is_edit($retval){
    	global $bp;
    	if (end($bp->action_variables) == 'edit') $retval = true;
    	return $retval;
    }
    add_filter('bbp_is_topic_edit','buddyboss_bbpress_is_edit', 10, 1);
    add_filter('bbp_is_reply_edit','buddyboss_bbpress_is_edit', 10, 1);
    
    function buddyboss_bbpress_form_reply_content($retval){
    	global $bp;
    	if (end($bp->action_variables) == 'edit' && in_array('topic', $bp->action_variables) && in_array('reply', $bp->action_variables)) {
    		$post = get_post( bbpress()->current_reply_id );
    		return esc_textarea( $post->post_content );
    	}
    }
    add_filter('bbp_get_form_reply_content','buddyboss_bbpress_form_reply_content', 10, 1);
    
    function buddyboss_bbpress_form_topic_content($retval){
    	global $bp;
    	if (end($bp->action_variables) == 'edit' && in_array('topic', $bp->action_variables) && !in_array('reply', $bp->action_variables)) {
    		$post = get_post( bbpress()->current_topic_id );
    	
    		return esc_textarea( $post->post_content );
    	}
    }
    add_filter('bbp_get_form_topic_content','buddyboss_bbpress_form_topic_content', 10, 1);
    
    function buddyboss_bbpress_form_title(){
    	global $bp;
    	if (end($bp->action_variables) == 'edit' && in_array('topic', $bp->action_variables) && !in_array('reply', $bp->action_variables)) {
    		$post = get_post( bbpress()->current_topic_id );
    		return esc_html( $post->post_title );
    	}
    }
    add_filter('bbp_get_form_topic_title','buddyboss_bbpress_form_title', 10, 1);
    
    //Filters bbpress admin links if on a group forum page.  Keeps users from being redirected to sitewide forums
    function buddyboss_reply_admin_links( $links, $args ) {
    	global $bp;
    	if (bp_current_action() == 'forum'){ 
    	$dom = new DOMDocument;
    		$dom->loadHTML($links);
    		
    		foreach ($dom->getElementsByTagName('a') as $node) {
    			//print_r($node);
    			if ($node->nodeValue == 'Edit'){
    				$forum = str_replace("/forums/forum/".$bp->groups->current_group->slug, "/groups/".$bp->groups->current_group->slug ."/forum", bbp_get_topic_permalink(bbp_get_topic_id()));
    				$reply = str_replace(site_url()."/forums/reply/","reply/",$node->getAttribute( 'href' ));
    				$node->setAttribute('href', $forum.$reply);
    			}
    			
    		}
    		$links = $dom->saveHTML();
    	}
    	return $links;
    }
    add_filter( 'bbp_get_reply_admin_links', 'buddyboss_reply_admin_links', 10, 2 );
    

    /buddypress/groups/single/plugins.php

    
    <?php
    global $bp;
    
    do_action( 'bp_before_group_plugin_template' );
    
    if (bp_current_action() == 'forum'){
    	if (empty($bp->action_variables)){  //Forum
    		$bp->groups->current_group->id;
    				$group_forum = groups_get_groupmeta( $bp->groups->current_group->id, $meta_key = 'forum_id');
    				$group_forum_id = $group_forum[0];
    
    				bbpress()->current_forum_id = $group_forum_id;
    				bbp_get_template_part('content','single-forum');	
    	} elseif (!empty($bp->action_variables) && !in_array("topic", $bp->action_variables) && !in_array("reply", $bp->action_variables)){ 
    		
    				bbp_get_template_part('content','single-forum');
    	} elseif (in_array("topic", $bp->action_variables) && !in_array("reply", $bp->action_variables)){  //Topic
    		if (bbpress()->current_view_id === 'edit'){
    			echo "<div id='bbpress-forums'>";
    			echo "<a href='".bbp_get_topic_permalink()."'><h4><img src='".get_stylesheet_directory_uri()."/images/back_button.png' />Back to Topic</h4></a>";
    			bbp_get_template_part('form','topic');
    			echo "</div>";
    		} else {
    			bbp_get_template_part('content','single-topic');
    		}
    	} elseif (in_array("topic", $bp->action_variables) && in_array("reply", $bp->action_variables)){ //Reply
    		if (bbpress()->current_view_id === 'edit'){
    			echo "<div id='bbpress-forums'>";
    			echo "<a href='".bbp_get_topic_permalink()."'><h4><img src='".get_stylesheet_directory_uri()."/images/back_button.png' /> Back to Topic</h4></a>";
    			bbp_get_template_part('form','reply');
    			echo "</div>";
    		} else {
    			bbp_get_template_part('content','single-reply');
    		}
    		
    	}	
    } else {
    	do_action( 'bp_template_content' ); 
    }
    ?>
    
    <?php do_action( 'bp_after_group_plugin_template' );
    
    Robkk
    Moderator

    you can place this code into your child themes functions.php file

    
    /**
     * Include bbPress 'topic' custom post type in WordPress' search results
     */
    function ntwb_bbp_topic_cpt_search( $topic_search ) {
    	$topic_search['exclude_from_search'] = false;
    	return $topic_search;
    }
    add_filter( 'bbp_register_topic_post_type', 'ntwb_bbp_topic_cpt_search' );
    
    /**
     * Include bbPress 'reply' custom post type in WordPress' search results
     */
    function ntwb_bbp_reply_cpt_search( $reply_search ) {
    	$reply_search['exclude_from_search'] = false;
    	return $reply_search;
    }
    add_filter( 'bbp_register_reply_post_type', 'ntwb_bbp_reply_cpt_search' );

    got the code from here, i see you also commented on it to ๐Ÿ™‚

    https://gist.github.com/ntwb/7363a1de1184d459f0c3

Viewing 25 results - 9,926 through 9,950 (of 32,519 total)
Skip to toolbar