| @@ -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 | /* |
| @@ -21,9 +23,11 @@ | ||
| 21 | 23 | // Get Forum Id for the current post |
| 22 | 24 | $post_id = $wp_query->post->ID; |
| 23 | 25 | $post_type = $wp_query->get('post_type'); |
| 24 | 26 | |
| 27 | + if (bbp_is_topic_super_sticky($post_id)) return true; | |
| 25 | 28 | |
| 29 | + | |
| 26 | 30 | $forum_id = private_groups_get_forum_id_from_post_id($post_id, $post_type); |
| 27 | 31 | //then call the function that checks if the user can view this forum, and hence this post |
| 28 | 32 | if (private_groups_can_user_view_post_id($forum_id)) |
| 29 | 33 | return true; |
| @@ -251,9 +255,10 @@ | ||
| 251 | 255 | |
| 252 | 256 | |
| 253 | 257 | //confirmed topic |
| 254 | 258 | if( bbp_is_topic( $post_id) ) { |
| 255 | - $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); | |
| 256 | 261 | //now we can check if the user can view this |
| 257 | 262 | if (!private_groups_can_user_view_post($user_id2,$forum_id_check)) |
| 258 | 263 | return; |
| 259 | 264 | return bbp_get_topic_author_link( $r ); |
| @@ -260,9 +265,10 @@ | ||
| 260 | 265 | |
| 261 | 266 | |
| 262 | 267 | // Confirmed reply |
| 263 | 268 | } elseif ( bbp_is_reply( $post_id ) ) { |
| 264 | - $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); | |
| 265 | 271 | //now we can check if the user can view this |
| 266 | 272 | if (!private_groups_can_user_view_post($user_id2,$forum_id_check)) |
| 267 | 273 | return ; |
| 268 | 274 | return bbp_get_reply_author_link( $r ); |
| @@ -268,10 +274,34 @@ | ||
| 268 | 274 | return bbp_get_reply_author_link( $r ); |
| 269 | 275 | } |
| 270 | 276 | // Neither a reply nor a topic, so could be a revision |
| 271 | 277 | //if it isn't a topic or reply, not sure so better to just not display the author in this case |
| 272 | - //could be revised to look up the post_parent of this post and then churn that round the code above if requiredreturn ; | |
| 278 | + //could be revised to look up the post_parent of this post and then churn that round the code above if required return ; | |
| 273 | 279 | return ; |
| 274 | 280 | |
| 275 | 281 | } |
| 276 | -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 | + | |
| 277 | 307 | ?> |