Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter laurahreniucu

    (@laurahreniucu)

    Found it. Don’t remember where now, found it some time ago. Just forgot to close this.

    Thanks.

    Hey Laura, do you remember where you were able to change the default doc permission? I want to make sure that when users using my site decide to create documents in their groups, by default, the doc permissions for ‘reading’ is automatically set to the group, rather than ‘anyone’

    Thanks in advance

    Thread Starter laurahreniucu

    (@laurahreniucu)

    Hi gabokappa.

    I’m not really sure, but i guess it was in “\plugins\buddypress-docs\includes\query-builder.php” in “set_up_levels” function

    Search for comment (should be around line 545)

    // The 'read' setting must also be saved to a taxonomy, for
     // easier directory queries

    Below this I have

    $read_setting = 'admins-mods';
     bp_docs_update_doc_access( $this->doc_id, $read_setting );

    I hope this solves your request.

    Take a look at functions.php line 445

    $default_settings = array(
    		'read'          => 'anyone',
    		'edit'          => 'loggedin',
    		'read_comments' => 'anyone',
    		'post_comments' => 'anyone',
    		'view_history'  => 'anyone',
    		'manage'        => 'creator',
    	);

    Wish there was a way to set this without hacking the bp docs core… still looking into that.

    OK so if I had looked a few lines down, I would have seen that there’s a filter right below that, you can set your defaults like this:

    function custom_bp_docs_permissions($doc_settings, $doc_id, $default_settings) {
    
      $custom_default_settings = array(
        'read'          => 'group-members',
        'edit'          => 'group-members',
        'read_comments' => 'group-members',
        'post_comments' => 'group-members',
        'view_history'  => 'group-members',
        'manage'        => 'group-members',
      );
    
      if($doc_id == 0 || $doc_settings == $default_settings) {
        return $custom_default_settings;
      } else {
        return $doc_settings;
      }
    
    }
    add_filter('bp_docs_get_doc_settings',custom_bp_docs_permissions,10,3);

    Hope this helps someone else out there…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Default doc permissions’ is closed to new replies.