WordPress.org

Support

Support » Plugins and Hacks » Role Scoper » [Resolved] Redirect users in user group to landing page x

[Resolved] Redirect users in user group to landing page x

  • I am using “Peter’s Login Redirect” to redirect users who log in to a landing page. I make landing pages per user group using WordPress Page Templates. Each landing page will have its own title and widgets. The problem is that this nice redirect plugin can redirect by user, redirect by role or by level. So not by Role Scoper’s user group. Does Role Scoper offer this functionality?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Perhaps I should just use conditional tags for the title and widgets, showing the proper title and widgets when need be. KevinB did give some code earlier:

    // 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
    }

    Just need to see where I can get the group ID and find a nice integration to show different blog titles and widgets per user group.

    Went into PMA and found user group nine for an added user group @ wp_user2group_rs . So that is a group I can use in my widget logic conditional tag for certain widgets:

    // 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 ] ) ) {
       // show or hide widget depending on widget
    }

    Working on the function now..

    $group_id_in_question = 9;   global $current_user; if ( isset( $current_user->groups[ $group_id_in_question ] ) ) { display;}

    Does not seem to work

    I tried

    $group_id_in_question = 9;
    $current_user = wp_get_current_user();
    global $current_user;
    if ( isset( $current_user->groups[ $group_id_in_question ] ) );

    in as a conditional in a widget logic widget. It does not show up at all..

    Thought I perhaps needed the user ID and then check if user ID is part of group nine:

    $group_id_in_question = 9;
    $current_user = wp_get_current_user();
    global $current_user;
    $user_id = $current_user->ID;
    if ( $user_id->groups[ $group_id_in_question ] );

    Not luck yet..

    <?php
    $group_id_in_question = 9;
    $current_user = wp_get_current_user();
    global $current_user;
    $user_id = $current_user->ID;
    if ( $user_id->groups[ $group_id_in_question ] ) echo "whatever";
    else
    echo "Sue me!";
    ?>

    Echoes “Sue me!” so I guess I made a mistake somewhere…

    widget logic code needs to return TRUE or FALSE so change it to something like:

    $current_user = wp_get_current_user(); return isset( $current_user->groups[ 9 ] );

    (note final semi-colon is essential)

    Thanks a lot for this!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Resolved] Redirect users in user group to landing page x’ is closed to new replies.
Skip to toolbar