PluginProbe
Private groups / 2.3
Private groups v2.3
trunk 1.5 1.6 1.7 1.8 1.8.1 1.9.1 1.9.2 2.0 2.0.1 2.2 2.3 2.4 2.5 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 All 116 releases
← All changes | includes/functions.php +31 -3 1.72.3 View file →
@@ -3,8 +3,10 @@
3 3 add_action('bbp_template_redirect', 'private_group_enforce_permissions', 1);
4 4 add_filter('protected_title_format', 'pg_remove_protected_title');
5 5 add_filter('private_title_format', 'pg_remove_private_title');
6 6 add_filter('bbp_get_forum_freshness_link', 'custom_freshness_link' );
7 +add_filter('bbp_get_author_link', 'pg_get_author_link' ) ;
8 +add_action ('bbp_user_register', 'pg_role_group') ;
7 9
8 10
9 11
10 12 /*
@@ -253,9 +255,10 @@
253 255
254 256
255 257 //confirmed topic
256 258 if( bbp_is_topic( $post_id) ) {
257 - $forum_id_check = private_groups_get_forum_id_from_post_id($post_id, 'topic');
259 + $topic=bbp_get_topic_post_type() ;
260 + $forum_id_check = private_groups_get_forum_id_from_post_id($post_id, $topic);
258 261 //now we can check if the user can view this
259 262 if (!private_groups_can_user_view_post($user_id2,$forum_id_check))
260 263 return;
261 264 return bbp_get_topic_author_link( $r );
@@ -262,9 +265,10 @@
262 265
263 266
264 267 // Confirmed reply
265 268 } elseif ( bbp_is_reply( $post_id ) ) {
266 - $forum_id_check = private_groups_get_forum_id_from_post_id($post_id, 'reply');
269 + $reply=bbp_get_reply_post_type() ;
270 + $forum_id_check = private_groups_get_forum_id_from_post_id($post_id, $reply);
267 271 //now we can check if the user can view this
268 272 if (!private_groups_can_user_view_post($user_id2,$forum_id_check))
269 273 return ;
270 274 return bbp_get_reply_author_link( $r );
@@ -274,6 +278,30 @@
274 278 //could be revised to look up the post_parent of this post and then churn that round the code above if required return ;
275 279 return ;
276 280
277 281 }
278 -add_filter('bbp_get_author_link', 'pg_get_author_link' ) ;
282 +
283 +
284 +//This function is added to bbp_user_register which in turn hooks to wordpress user_register. It checks if the user role has a group set against it, and if so assigns that to the user
285 +
286 +function pg_role_group ($user_id) {
287 +$test=get_option ('rpg_roles') ;
288 +//if no roles set, then exit
289 +if (empty ($test)) return ;
290 +//we have roles set, so now cycle through the roles for this user
291 +//$user_id = get_current_user_id();
292 +//if ($user_id == 0) return ; // bail if no user ID
293 + $roles = get_usermeta( $user_id, 'wp_capabilities',false ) ;
294 + foreach ($roles as $role=>$value) {
295 + foreach ($test as $check=>$group){
296 + if ($role == $check ) {
297 + if ($group != 'no-group') update_user_meta( $user_id, 'private_group', $group);
298 + }
299 + }
300 + }
301 +}
302 +
303 +
304 +
305 +
306 +
279 307 ?>