Skip to:
Content
Pages
Categories
Search
Top
Bottom

Misunderstanding: buddypress groupforums usage


  • Apokh
    Participant

    @apokh

    Hey there,

    I have a Installation with bbpress and buddypress.
    For different Groups in Buddypress I wanted to make Group forums. So I created a Group “Group1″.
    I also created a “forum group” for Group 1. I also made some more forums with “Group 1″ Forum Group as parent.

    I THOUGHT now, that all members ans ONLY those members of Group 1 would have access to “Group 1″ Forum Group with all the Forums benath that one.

    But thats not working that way, right? All registered member can see the “childforums” of Group 1. Red them and post there. Thats not what I intended to do. When I make the childforums to “private” even the Groupmembers cannot see them.

    That´s how it is.
    Woul perhaps someone give me a hint, where my mind is wrong with that?
    Its really urgent.
    Tahks in advance.
    Apokh

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

  • Apokh
    Participant

    @apokh

    Nobody?
    Come on, this must be recognized by someone except me?!


    Robin W
    Moderator

    @robin-w

    Sorry, I don’t run buddypress.

    You might do better on the buddypress support forum

    http://buddypress.org/support/

    Have you tried

    http://codex.buddypress.org/getting-started/installing-group-and-sitewide-forums/

    and there is also talk of

    http://wordpress.org/plugins/private-bp-pages/

    and what have you set visibility within bbp to be eg

    http://codex.bbpress.org/step-by-step-guide-to-setting-up-a-bbpress-forum/ section 5


    jyd44
    Participant

    @jyd44

    You are right. Having the same requirement, I was facing the same issue (and you will discover very soon that it is not the only one !).
    As far as I understand, the integration between bbPress and BuddyPress is not fully completed. In bbPress, the user capabilities based on their role in the forums are only mapped to WP capabilities. (see for example the function bbp_current_user_can_publish_replies() or bbp_current_user_can_access_create_reply_form() (invoqued in the form-reply.php part of the bbPress theme) in bbpress/includes/users/template.php .
    My way to overcome this issue is to add my own filter on the ‘bbp_current_user_can_publish_replies’ filter and to check in this function if the current_user is a member of the group associated with the root_forum (the one associated with the group) of the topic currently displayed.

    below my function:

    function my_bbp_current_user_can_publish_replies($input)
    	{
    		$topic_id = bbp_topic_id();
    		$root_forum = alsb_get_post_root_forum($topic_id);
    		$groups_id = bbp_get_forum_group_ids($root_forum);
    		$user_id = get_current_user_id();
    		if (groups_is_user_admin( $user_id, $groups_id[0])
    			|| groups_is_user_mod ($user_id, $groups_id[0]) 
    				|| groups_is_user_member ($user_id, $groups_id[0]) )
    			return true;
    		else return false;
    	}
    
    whith the help function
     	function alsb_get_post_root_forum($post_id)
    	{
    		$post = get_post($post_id);
    		do
    		{
    			$post = get_post($post->post_parent);
    		}while ($post->post_parent != 0);
    		return $post->ID;
    	}
    

    another way is perhaps to setup a filter on the ‘user_has_cap’ WP filter, but I did not test it.
    good luck for your integration !


    Apokh
    Participant

    @apokh

    Okay the first part is to replace the function within the template.php but where goes the second one? function alsb_get_post_root_forum($post_id)

    I´m not php common, so di I have to replace the whole function bbp_current_user_can_publish_replies()function within the template.php with your code?


    jyd44
    Participant

    @jyd44

    My proposal is based on the hook mechanism proposed by WP and that bbPress use intensely, giving a lot of possibilities for (business) logic customisation. This is not related to the templates files in the theme, which are more related to the presentation (how the informations are displayed). Restricting the possibility to make a reply to the member of a group is a pure “business logic” requirement. You may find few explanations on how it works in the part 5 of the step by step documentation on this site.

    You add the two functions in the functions.php file of your theme.
    In the same file, add the following line, for instance after the two functions or at the end of the file:
    add_filter (‘bbp_current_user_can_publish_replies’, my_bbp_current_user_can_publish_replies, 10);

    This is the way you install filter under WP.

    PS: you can replace the test: if (groups_is_user_admin( $user_id, $groups_id[0])
    || groups_is_user_mod ($user_id, $groups_id[0])
    || groups_is_user_member ($user_id, $groups_id[0]) )

    by this one, which is sufficient for your purpose:
    if ( groups_is_user_member ($user_id, $groups_id[0]) ) return true;


    Apokh
    Participant

    @apokh

    Okay thank you so much. I´ll try that out next days.


    Apokh
    Participant

    @apokh

    Okay I declared the 2 Functions

    function my_bbp_current_user_can_publish_replies($input)
    {
    $topic_id = bbp_topic_id();
    $root_forum = alsb_get_post_root_forum($topic_id);
    $groups_id = bbp_get_forum_group_ids($root_forum);
    $user_id = get_current_user_id();
    if (groups_is_user_admin( $user_id, $groups_id[0])
    || groups_is_user_mod ($user_id, $groups_id[0])
    || groups_is_user_member ($user_id, $groups_id[0]) )
    return true;
    else return false;
    }
    
    function alsb_get_post_root_forum($post_id)
    {
    $post = get_post($post_id);
    do
    {
    $post = get_post($post->post_parent);
    }while ($post->post_parent != 0);
    return $post->ID;
    }
    
    add_filter (‘bbp_current_user_can_publish_replies’, my_bbp_current_user_can_publish_replies, 10);

    within my themes function.php. It seems to work, but only for the Parent Forum, not for their child forums.

    So when i have

    Parent (Private buddypress rootforum for Goup)
    — Child 1
    — Child 2

    Only the Parent is “safe”, when I click as non-member of the group in the forum index on one of the Children, I have access, can read and post. Seems the Access Control of bbpress cannot compete in direct comparism to the forumintegrations of other CMS´. I´m asking how other users do realize their communities with buddypress (which is based on a really good idea) in comnbination with bbpress as forum.


    jyd44
    Participant

    @jyd44

    Hi,
    your initial question was about replies. In fact, you have exactly the same issues for posting, reading, and so on. You have to use the same kind of trick for every action you want to block.
    The best way to find which filter is key to control an action, is to start from the template files, to see which bb_call is made, read the source code of this function and discover which filter is applied. It’s the same also for the buddypress menus (either in the admin bar, either in the body of the page), depending on your requirements (eg. Do you allow a non member to discover the list of member in a group, and so on.)
    Yes it’s a huge job. When you complain about the way the access control in bbpress is handled, remember that I told you before that blocking the access to replies will not be the only one issue you will have to face. With roughly the same requirements, I have written more than 1800 lines of code (including comments !) to tune the menus and to refine the access control rules. Fortunately, thanks to the filter and action mechanism of WP and the goodwill of their developpers, bbPress and BuddyPress offer many possibilities for this tuning.

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

You must be logged in to reply to this topic.