Skip to:
Content
Pages
Categories
Search
Top
Bottom

Open groups: Let all members post in every group without joining


  • mikeboltonca
    Participant

    @mikeboltonca

    Hi folks,

    I use BuddyPress as part of a company intranet. Our BuddyPress Groups are used as a quick way to find who works in a particular department or location.

    For our purposes, it makes sense for any staff member to be able to use any groups’ activity stream and bbPress forums, without having to join that group. The only exceptions would be for hidden groups, such as our Management group; they should still be invisible to non-members.

    I’ve already solved half the problem by creating a plugin that allows any member to participate in any group’s bbPress forum: Read forum topic.

    The next challenge is to allow anyone to post on any group’s activity stream (i.e. Home page).
    There are two parts:
    Show the “What’s new?” form to non-members
    To do this, we can modify the template for /groups/single/activity.php.
    If we change line 52 from: <?php if ( is_user_logged_in() && bp_group_is_member() ) : ?> to: <?php if ( is_user_logged_in() ) : ?>, the template will no longer check if the user is a member anymore, so the “What’s new?” form will show up for everyone.

    At this point, if a non-member tries to write an activity post, the following error message appears:

    There was a problem posting your update. Please try again.

    I’d guess the action of posting checks if the user has permission to do so. Since they don’t, the post fails.

    Allow users to write activity posts without joining the group
    This is where I’m stuck.
    I’ve tried to use the translation file to track down the function that’s throwing the error. The There was a problem posting your update. Please try again. line reference points to bp-templates/bp-legacy/buddypress-functions.php:950 (this is actually line 962 now). If I change the error message directly on that line, the change isn’t reflected on the page. That tells me the error is coming from somewhere else.

    I would love a bit of insight on which files are involved once the user clicks “Post”.
    As always, I’ll report back with my full solution if I figure this out.

    Thanks for any help you can provide!

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

  • shanebp
    Moderator

    @shanebp

    Yup, it’s failing on groups_is_user_member() in bp-groups\bp-groups-functions.php.

    You could hack that function, but I think what you really need is a filter hook on the return.
    Then your task would be simple.

    groups_post_update() in bp-templates\bp-legacy\buddypress-functions.php uses groups_is_user_member()

    You could create an enhancement ticket on trac.


    mikeboltonca
    Participant

    @mikeboltonca

    Thanks for the quick reply, Shane.

    At least I know exactly what obstacle I’m dealing with now. That simplifies my options a lot.

    I might submit an enhancement ticket. It may be denied under the assumption that the filter hook wouldn’t be valuable to enough people, it’s certainly worth a shot.

    I really appreciate your insight. You’ve just saved me a lot of time!


    mikeboltonca
    Participant

    @mikeboltonca

    Shane, I wonder if you can help me stitch together the sequence of events between clicking “Post” on the “What’s new?” form and the moment that groups_is_user_member() is called.

    I’m wondering if there might be an intermediary step I could modify so it doesn’t perform the member check in this particular case.

    I still need groups_is_user_member() intact to keep non-managers out of the Management group, so hacking that function directly (or filtering it across the board) won’t do the job for me.

    Thanks again for your insight. BuddyPress is a gloriously complex system, and it takes a long time to reverse-engineer it by reading docs and looking through the files.


    mikeboltonca
    Participant

    @mikeboltonca

    I’ve submitted an enhancement Trac here: https://buddypress.trac.wordpress.org/ticket/7489#ticket.

    In the meantime, I’ve implemented the following hack to allow non-members to post on a group’s activity stream:
    In /plugins/buddypress/bp-groups/bp-groups-functions.php, comment out lines 1215 and 1216.

    Original:

    if ( !bp_current_user_can( 'bp_moderate' ) && !groups_is_user_member( $user_id, $group_id ) )
    	return false;

    Hacked:

    //if ( !bp_current_user_can( 'bp_moderate' ) && !groups_is_user_member( $user_id, $group_id ) )
    	//return false;

    This removes the check for “Is this an admin or a group member?”, allowing anyone to post.


    binaryfabric
    Participant

    @binaryfabric

    @mikeboltonca

    I know its been awhile but were you ever able to figure this out without changing the core files?

    Thanks,


    mikeboltonca
    Participant

    @mikeboltonca

    Sorry for the delay in replying, @binaryfabric. I just happened to notice your message in my spam folder.

    I didn’t make any more progress with that problem, unfortunately. I’ve also changed jobs and don’t manage that project anymore. Good luck to you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar