• tdwnyc

    (@tdwnyc)


    Hi,
    Is it possible to restrict use of BP Docs so that only groups have access to it?
    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author David Cavins

    (@dcavins)

    Hi @tdwnyc-

    Try starting with this plugin that keeps editing and such within the group framework: https://github.com/boonebgorges/buddypress-docs-in-group

    It could be complicated to disable the main Docs archive (I’m not sure, I’ve never tried, but a cursory glance at the code doesn’t show anything obvious.)

    You could disable the user profile Docs tab using the BP navigation API: https://codex.buddypress.org/developer/navigation-api/

    The code for that would be something like:

    add_action( 'bp_actions', function() { 
    	bp_core_remove_nav_item( 'docs' ); 
    } );

    (and would go in your theme’s functions.php file or in bp-custom.php: https://codex.buddypress.org/themes/bp-custom-php/)

    The plugin “buddypress-docs-in-group” seems to be outdated now. I tried it on my install and it got caught in some type of loop.

    Would it be possible to just force choosing a group when creating a document instead of having the option to select “none”?

    I only want groups to be able to create documents, so I was thinking that when a user goes to create a document if their only choice was a list of groups they belong to it would solve the problem.

    It would be nice if there was a setting to control who could create documents in the group also. Like only the owner or moderator or all group members.

    • This reply was modified 5 years, 12 months ago by micster. Reason: typo
    Plugin Author David Cavins

    (@dcavins)

    Hi @micster-

    The docs-in-group plugin mostly worked well for me in my recent test. I was able to update one piece that was causing odd behavior because of a recent change to BuddyPress. I’ve created a pull request to fix the issue and imagine that the plugin author will review it pretty soon.

    In vanilla BP Docs, there is a setting for choosing who can associate docs with each group. Visit a group’s “Manage” section, then look for the “Docs” tab. You can choose to enable/disable docs for the group and set the “Minimum role to associate Docs with this group”.

    You could require that users select a group when using the create/edit form. You could do this via JavaScript form validation, like this: https://www.tutorialspoint.com/javascript/javascript_form_validations.htm

    Or you could refuse to save it if “none” were selected. There’s a handy action point for that: https://github.com/boonebgorges/buddypress-docs/blob/master/includes/query-builder.php#L497

    Something like the following added to your bp-custom.php would probably work:

    add_filter( 'bp_docs_filter_result_before_save', function( $result, $args ) {
    	if ( empty( $args['group_id'] ) ) {
    		$result['error'] = true;
    		$result['message'] = 'You must choose a group.';
    	}
    	return $result;
    }, 10, 2 );

    Have fun!

    Thanks David!

    I think your code above for refusing to save if no group is chosen along with the other code to hide the menu item will achieve what I want.

    I appreciate the help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘BP Docs For Groups Only?’ is closed to new replies.