boonebgorges / buddypress-docs

GNU General Public License v3.0
106 stars 44 forks source link

bp_docs_get_default_access_options filters are not respected when a group is selected. #703

Open dcavins opened 2 years ago

dcavins commented 2 years ago

Filtering default doc settings via the filter bp_docs_get_default_access_options works as expected when the doc is not group-related. However, if you choose to associate the new doc with a group, the filter isn't effective. I believe the issue is the first line in bp_docs_access_options_helper() where the type is set to raw when a group_id is passed. https://github.com/boonebgorges/buddypress-docs/blob/master/includes/templatetags.php#L1160

I wonder if that check shouldn't be "set type to raw when a doc_id is passed"? Maybe "raw" should never be used here? Or maybe there is a reason that the group_id would matter here. I'm not sure. :)

This issue was pointed out here: https://wordpress.org/support/topic/how-do-i-set-the-default-permissions-for-a-group-doc/

boonebgorges commented 2 years ago

For reference, here's where the 'raw' call for groups was introduced https://github.com/boonebgorges/buddypress-docs/commit/d58c86832f9abafd54ff93b381afb38d0087f84f It's not clear to me why I went this route, either from the changeset or from the associated issue #414.

The main purpose of 'raw', if I'm understanding bp_docs_get_doc_settings() correctly, is to prevent the saved settings from being parsed with the defaults. But I'm not sure why you'd ever want to do that, since it would leave empty values.

@dcavins If you want to experiment with removing the 'raw' call, please feel free. Based on #414, you'd want to check whether the default settings are working properly with private/hidden groups, to avoid a regression.