• Resolved fredhead

    (@fredhead)


    In RS, I have created groups. In my right column sidebar, I want to display links based on what group the user belongs to.

    What RS function(s) can be used to display content based on group assignment? And, if that’s possible, what arguments are passed to the function? Can I also assume the argument is the exact group name as defined in Users > Role Groups?

    I see is_restricted_rs() and users_who_can() are available but it is unclear to me what arguments these functions take and precisely how they function.

    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Did you ever figure this out? I am also looking for this.

    Thread Starter fredhead

    (@fredhead)

    No response yet. However, Kevin was on vacation a week or two ago. I plan to ping him this weekend, to see if he is around. He’s conscientious.

    Also, FWIW, this particular topic is mentioned in his documentation as a work in progress.

    Checking out his documentation/forum now. Thanks for the feedback fredhead!

    What RS function(s) can be used to display content based on group assignment?

    // substitute actual group ID here (id argument in edit links on User > Role Groups)
    $group_id_in_question = 12; 
    
    global $current_user;
    if ( isset( $current_user->groups[ $group_id_in_question ] ) ) {
       // do stuff
    }

    Thanks for that kevinB. Will play with this on a site in progress

    Thread Starter fredhead

    (@fredhead)

    Thanks, Kevin!

    I tried the following in a php widget:

    $group_id_in_question = 9;
    $current_user = wp_get_current_user();
    $user_id = $current_user->ID;
    if ( isset( $current_id->$group_id[ $group_id_in_question ] ) ) echo "www";
    else
    echo "hhh";

    But hhh is shown so if statement does not work.

    // substitute actual group ID here (id argument in edit links on User > Role Groups)
    $group_id_in_question = 9; 
    
    global $current_user;
    if ( isset( $current_user->groups[ $group_id_in_question ] ) ) {
      echo "hhh";
    }

    Seems to work sometimes…. It just does not using the widget logic widget with the same code. Very odd. Will try again tomorrow

    let me correct last statement.

    <?php
    // substitute actual group ID here (id argument in edit links on User > Role Groups)
    $group_id_in_question = 9; 
    
    global $current_user;
    if ( isset( $current_user->groups[ $group_id_in_question ] ) ) {
      echo "hhh";
    else
    echo "Nope";
    }
    ?>

    Does not run either. Only the PHP widget title not part of the if else statement is shown. Neither the if nor the else echo is shown.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Role Scoper: Conditional Data Display Functions?’ is closed to new replies.