Skip to:
Content
Pages
Categories
Search
Top
Bottom

Link to User’s Group’s Forums


  • rda5009
    Participant

    @rda5009

    Hello,

    I am on WP version 4.5.2 and am trying to create a way to link directly to the user’s group’s forums. Ideally, I would like the navigation menu to update with their group forum. For instance, if the user is a group member of Car Club, on the navigation menu you would see Forums>Car Club Forum, where Car Club Forum is the forum associated with the Car Club group.

    Otherwise, I could create a dashboard type page where it pulls in the bbpress group forums associated with the user. Using the example above, the user would click on Forum and would see a page populated with the Car Club Forum.

    I prefer the first solution, but the second one would work too. Any help is greatly appreciated.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

  • rda5009
    Participant

    @rda5009

    Any ideas on where to be able to start with this?


    sharmavishal
    Participant

    @sharmavishal

    “bbpress group forums associated with the user” this is not possible. you can associate bbpress forums to a specific group only

    Installing Group and Sitewide Forums


    rda5009
    Participant

    @rda5009

    @sharmavishal

    Thanks for the quick reply. I understand that the bbpress forums are associated with the group from Groups and then associating the group with the forum on under Discussion Forum on the right. The part after this is the part I’m stuck at. I want to display that forum in the menu if and only if the user is a member of that group.

    So if User A is a member of Group A, I want a way to display Group A’s forum in the nav menu. Hopefully this makes sense.

    Menus aren’t very php-friendly, usually, but you could do something like this:

    
    <?php
    if ( groups_is_user_member( bp_loggedin_user_id(), $group_id_of_group_A ) ) {
    	$group = groups_get_group( array( 'group_id' => $group_id_of_group_A ) );
    	?>
    	<li><a href="<?php echo bp_get_group_permalink( $group ) . 'forum/'; ?>"><?php bp_group_name( $group ) ?> Forum</a></li>
    	<?php
    }
    

    You may have to hook onto wp_nav_menu_items or similar to inject the link. It depends on your theme. That would look like:

    add_filter( 'wp_nav_menu_items', 'my_inject_group_forum_link_into_menu' );
    my_inject_group_forum_link_into_menu( $items ) {
    	if ( groups_is_user_member( bp_loggedin_user_id(), $group_id_of_group_A ) ) {
    		$group = groups_get_group( array( 'group_id' => $group_id_of_group_A ) );
    		$items .= '<li><a href="' . bp_get_group_permalink( $group ) . 'forum/">' . bp_get_group_name( $group ) . 'Forum</a></li>';
    		<?php
    	}
    	return $items;
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar