ok thanks for posting, and in particular for a great problem definition – usually I need a couple of exchanges to get to the issue.
On issue 1.
I’ll need to check quite what I hooked to, but from memory, the current code looks to assign a user to the appropriate private group IF they have no current private groups assigned, and their roles says they should.
The logic behind this was that you might want an individual within a role set to have different rights, so the code doesn’t apply logic to anoyone who has already got a group.
I could add logic to do as you require, and this would probably be a good idea. Not sure of timescale – I’m away this weekend. I’ll come back to you after the weekend when I can look at what is involved.
issue 2.
Are you talking about sticky or super-sticky? Again I’ll take a look after the weekend
Hello Robin. Thank you for taking your time to help me with this.
Regarding issue nr.2 I am talking about super-sticky.
Regarding issue nr.1 I have made a front end user edit screen so that the site admin can edit users without going to the dashboard.
The post method looks like this:
if ( !empty( $_POST['role'] ) )
wp_update_user(array('ID' => $user_id,'role' => esc_attr( $_POST['role'])));
Maybe here I can also add a code to update the user (overwrite the role) also in bbP private group?
In effect you’d need a bit of logic that either said
1.
If $_post[‘role’] isn’t equal to the current user-id role on the database (ie the role has changed) then update the private groups
or
2. in all cases update the private groups (ie do not worry about whether the role has changed, just update every time a moderator uses the front end edit user.
If roles always equate to private groups permissions, then no. 2 would be fine.
You’d need to test, but I suspect you could just call in either case (obviously bound in an if statement for option 1).
pg_role_group ($user_id);
This should call and set the user to the current database role, but make sure you call it after the wp_update_user so that it is the new one.
If that works, then fantastic, if not do come back and I’ll look deeper into the code.
on issue 2 – supersticky topics appear in every forum, so if you have a mixture of public an private forums, then I can’t easily hook to make them only appear in the private groups.
Can you explain a bit more about quite what these super sticky topics are? ie is there a reason why you can’t just have a separate sticky topics for each forum – albeit that they may have the same content which you could copy/paste.
If I can understand better, I can probably help with a solution.
Hi Robin.
Thank you for the clue. I have figured out how to change role and private group together. Below is the code. Now I will try to play with stickies and super stickies…
if ( !empty( $_POST['role'] ) ) {
wp_update_user(array('ID' => $user_id,'role' => esc_attr( $_POST['role'])));
global $rpg_roles ;
$user_info = get_userdata($user_id);
$user_roles = $user_info->roles ;
foreach ((array)$user_roles as $list=>$role) {
$group = $rpg_roles[$role] ;
update_user_meta( $user_id, 'private_group', $group);
}
}
Regarding stickies, unfortunately simple “stick” is not good for our forum, because we treat individual forums more like categories, and so most of the time we see all topics (from different forums-categories) in one page. Individual forums-categories are rarely visited. So we need to use super-stickies in order to highlight the important topics at the top of the whole topics list.
I guess the if statement logic should be something similar to this:
if is_super_sticky && is_in_the_forum_that_user_can_not_access
then redirect to restricted-access.php
Can this work? Any other ideas?
Or, we can just move simple stickies to the top of the whole topics list. We are using this shortcode to display topics: [bbp-topic-index]
Because now the list is displayed: most recent on top. Stickies are treated similar as simple topics.
If we can get stickies to be displayed on top (sort by recent), and then simple topics (sort by recent-as it is now), that would solve the problem.
thanks, just returned from being away, so I’ll look at this as soon as I can, but lots of ‘work’ emails to get through first !
Hi Robin. I continue playing with stickies and super stickies and it becomes clear that stickies should be used instead of super stickies.
But then there is the same question: how to move stickies to the top of the topics list that is shown by [bbp-topic-index] shortcode? Any ideas?
I think a shortcode in my style pack will do this, and filters on private groups, so should show what you want.
Can I trouble you to test as I’m tight on time at the moment, and if it doesn’t work come back and I’ll find a slot to look in details
so install and activate
https://wordpress.org/plugins/bbp-style-pack/
and then go to settings>bbp style pack and look at the shortcodes tab for details on what to put in eg
[bsp-display-topic-index show='6' show_stickies='true']
I tried this and similar shortcode with style pack plugin but it doesn’t work. Also we try to use as less plugins as possible.
I guess, for now I stick with simple stickies and will try to figure out how to move them to the top when [bbp-topic-index] shortcode is used.
ok, if you want me to peruse further let me know, but I’ll mark this as resolved for the moment
Ok, great, thanks for the answers! If no success on my own, I will probably ask for help again 🙂 Thanks!