WordPress.org

Ready to get started?Download WordPress

Forums

Role Scoper
[resolved] Redirect users in user group to landing page x (9 posts)

  1. Rhand
    Member
    Posted 3 years ago #

    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?

  2. Rhand
    Member
    Posted 3 years ago #

    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.

  3. Rhand
    Member
    Posted 3 years ago #

    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..

  4. Rhand
    Member
    Posted 3 years ago #

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

    Does not seem to work

  5. Rhand
    Member
    Posted 3 years ago #

    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..

  6. Rhand
    Member
    Posted 3 years ago #

    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..

  7. Rhand
    Member
    Posted 3 years ago #

    <?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...

  8. alanft
    Member
    Posted 3 years ago #

    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)

  9. Rhand
    Member
    Posted 3 years ago #

    Thanks a lot for this!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic