• Resolved strategeek

    (@strategeek)


    Hello.

    I have two questions:

    1. I have made custom roles with User Role Editor plugin. I have assigned these roles to private groups in bbP private groups plugin settings and checked “Add group on login”.

    When I create new users with custom roles it works well – custom roles see only forums that are assigned to them. But when I change the role of existing user, this doesn’t affect bbP private groups plugin, even after log in/log out. The member sees the same forums that were assigned to initial custom role that was set during user creation process.

    In short, it works like that:
    New user->Custom “role1”->Sees private “group1” that is set for “role1”
    User edit->Change to “role2”->Still sees private “group1” that is set to “role1”

    Is bbP private groups plugin supposed to work like that? If yes, is there a way to change this?

    2. When I make sticky topics, they are seen by everyone, even though the topics are in private groups. Is there a way to make sticky topics visible only to those who are part of the private groups?

    Thank you for the nice plugin. Hope that you can help with my questions.

    https://www.ads-software.com/plugins/bbp-private-groups/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Robin W

    (@robin-w)

    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

    Thread Starter strategeek

    (@strategeek)

    Hello Robin. Thank you for taking your time to help me with this.

    Regarding issue nr.2 I am talking about super-sticky.

    Thread Starter strategeek

    (@strategeek)

    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?

    Plugin Author Robin W

    (@robin-w)

    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.

    Plugin Author Robin W

    (@robin-w)

    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.

    Thread Starter strategeek

    (@strategeek)

    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);
    		}
    		}
    Thread Starter strategeek

    (@strategeek)

    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?

    Thread Starter strategeek

    (@strategeek)

    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.

    Plugin Author Robin W

    (@robin-w)

    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 !

    Thread Starter strategeek

    (@strategeek)

    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?

    Plugin Author Robin W

    (@robin-w)

    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://www.ads-software.com/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']
    Thread Starter strategeek

    (@strategeek)

    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.

    Plugin Author Robin W

    (@robin-w)

    ok, if you want me to peruse further let me know, but I’ll mark this as resolved for the moment

    Thread Starter strategeek

    (@strategeek)

    Ok, great, thanks for the answers! If no success on my own, I will probably ask for help again ?? Thanks!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Role change and Sticky posts’ is closed to new replies.