| 104 |
104 |
|
| 105 |
105 |
// Adds a hidden input value to the "Group Settings" page
|
| 106 |
106 |
add_action( 'bp_before_group_settings_admin', array( $this, 'group_settings_hidden_field' ) );
|
|
107 |
|
|
108 |
// Do the following on a group forum page.
|
|
109 |
if ( function_exists( 'bp_core_get_query_parser' ) && 'rewrites' === bp_core_get_query_parser() ) {
|
|
110 |
add_action( 'bp_parse_query', array( $this, 'on_group_forum_page' ) );
|
|
111 |
} else {
|
|
112 |
$this->on_group_forum_page();
|
|
113 |
}
|
| 107 |
114 |
}
|
| 108 |
115 |
|
| 109 |
116 |
/**
|
| ... | ... | |
| 144 |
151 |
// Restrict private and hidden group forums outside of group requests
|
| 145 |
152 |
add_filter( 'bbp_map_meta_caps', array( $this, 'map_group_forum_read_meta_caps' ), 20, 4 );
|
| 146 |
153 |
add_filter( 'bbp_get_excluded_forum_ids', array( $this, 'exclude_group_forum_ids' ), 20 );
|
|
154 |
}
|
| 147 |
155 |
|
| 148 |
|
/** Caps **************************************************************/
|
| 149 |
|
|
|
156 |
/**
|
|
157 |
* Do the following on a group forum page.
|
|
158 |
*
|
|
159 |
* @since X
|
|
160 |
*/
|
|
161 |
public function on_group_forum_page() {
|
| 150 |
162 |
// Only add these filters if inside a group forum
|
| 151 |
163 |
if ( bp_is_single_item() && bp_is_group() && bp_is_current_action( $this->slug ) ) {
|
|
164 |
// Remove exclude forum IDs filter if group is public or if user is a group member.
|
|
165 |
if ( 'public' === bp_get_group_status( groups_get_current_group() ) || false !== groups_is_user_member( get_current_user_id(), bp_get_current_group_id() ) ) {
|
|
166 |
remove_filter( 'bbp_get_excluded_forum_ids', array( $this, 'exclude_group_forum_ids' ), 20 );
|
|
167 |
}
|
| 152 |
168 |
|
| 153 |
169 |
// Ensure bbp_is_single_forum() returns true on group forums.
|
| 154 |
170 |
add_filter( 'bbp_is_single_forum', array( $this, 'is_single_forum' ) );
|
| ... | ... | |
| 402 |
418 |
* @return array
|
| 403 |
419 |
*/
|
| 404 |
420 |
public function map_group_forum_meta_caps( $caps = array(), $cap = '', $user_id = 0, $args = array() ) {
|
|
421 |
$caps_to_check = [
|
|
422 |
'publish_replies', 'publish_topics', 'moderate', 'edit_topic', 'edit_reply', 'view_trash', 'edit_others_replies', 'edit_others_topics', 'delete_topic', 'delete_reply', 'manage_forum_attributes'
|
|
423 |
];
|
|
424 |
|
|
425 |
// If not checking our caps, bail.
|
|
426 |
if ( ! in_array( $cap, $caps_to_check ) ) {
|
|
427 |
return $caps;
|
|
428 |
}
|
|
429 |
|
| 405 |
430 |
// Group request state only describes the logged-in user
|
| 406 |
431 |
if ( bbp_get_current_user_id() !== (int) $user_id ) {
|
| 407 |
432 |
return (array) apply_filters( 'bbp_map_group_forum_topic_meta_caps', $caps, $cap, $user_id, $args );
|