WordPress.org

Ready to get started?Download WordPress

Forums

User Access Manager
[Question]Redirect user after login (11 posts)

  1. Bigua
    Member
    Posted 2 years ago #

    Hi,

    With this plugin can I redirect a user after login to a specific page? I want to make sub homepages for each group and need to redirect every user after logon to this custom pages.

    Thanks in advance and sorry by my english

    http://wordpress.org/extend/plugins/user-access-manager/

  2. aspero
    Member
    Posted 2 years ago #

    Hi,

    I also needed this functionality. I modified peters' login redirect plugin

    1. Install the latest version of peters' login redirect - 2.5.3
    http://wordpress.org/extend/plugins/peters-login-redirect/

    2. Replace /wp-content/plugins/peters-login-redirect/wplogin_redirect.php
    with the following file:

    http://www.rajewski.pl/code/wplogin_redirect.zip

    3. One DB modification is needed - add "group" type of redirect:

    ALTER TABLE wp_login_redirects CHANGE rul_type rul_type ENUM( 'group', 'user', 'role', 'level', 'all', 'register' )

    4. Setup groups in UAM and create redirect links in Peters' Login Redirect admin panel.

    Backdraws:
    - Peters' Login Redirect plugin update will of course overwrite modified file.
    - Deleting UAM group doesn't delete redirects - you have to do it manually (but I used ID's (with autoincrease) instead of names, so these records shouldn't cause any problems.

  3. aspero
    Member
    Posted 2 years ago #

    wplogin_redirect.zip updated (with a few fixes).

  4. drsim
    Member
    Posted 1 year ago #

    aspero,
    thanks for your modifications..
    i am using wp-members plugins for groups.
    and your changes not showing me groups in admin panel settings of login/logout redirects..
    Any help would be appreciated.
    thanks

  5. jlipford
    Member
    Posted 1 year ago #

    I was able to integrate with Role Scoper in the way. I basically just used the wp_groups_rs table instead of UAM.

    great custom solution!

  6. aspero
    Member
    Posted 1 year ago #

    Hi drsim,

    In your case you have to examin wplogin_redirect.php and make some modifications concerning DB tables (I think) - just like jlipford did.

    Thank you jlipford for your nice feedback :)

    Bartek.

  7. drsim
    Member
    Posted 1 year ago #

    Thanks jlipford and aspero..
    i have changed the DB queries according to wp members plugin, everything works , it is even saving the redirects in admin panel, but it is not redirecting after login,, i am using /wp-login.php page to test and it redirect the user to the profile page instead of the group page.
    any idea ??
    thanks

  8. drsim
    Member
    Posted 1 year ago #

    i think i have found the problem..
    $user_has_groups = $wpdb->get_results('SELECT group_id FROM '.$wpdb->prefix . 'uam_accessgroup_to_object WHERE object_type = \'user\' AND object_id = '.$user->ID, OBJECT);

    above is your query and below is what i have..

    $user_has_groups = $wpdb->get_results('SELECT grel_group_id FROM '.$wpdb->prefix . 'ps_group_relationships WHERE grel_user_id = '.$user->ID, OBJECT);

    i was assuming that object_id is user id, but it is the page id ,, so in wp member plugin , it does not save the page id in groups relationship table..
    how can i get around with that??

  9. aspero
    Member
    Posted 1 year ago #

    Did you

    ALTER TABLE wp_login_redirects CHANGE rul_type rul_type ENUM( 'group', 'user', 'role', 'level', 'all', 'register' )

    ?

  10. drsim
    Member
    Posted 1 year ago #

    Yes i did. and i did some further debuging..

    when i execute in sql ...

    $user_has_groups = $wpdb->get_results('SELECT grel_group_id FROM '.$wpdb->prefix . 'ps_group_relationships WHERE grel_user_id = '.$user->ID, OBJECT);

    above query return the group id.
    then...

    $rul_users = $wpdb->get_results('SELECT rul_value, rul_url FROM ' . $rul_db_addresses .
           	' WHERE rul_type = \'group\' AND rul_value = '.$user_has_groups[0]->group_id , OBJECT);

    it returns the rul_value and rul_url..

    but

    if ($rul_users) {
        		{
           			foreach( $rul_users as $rul_user )
           			{
    				echo $rul_user->rul_url;
               			$redirect_to = rulRedirectFunctionCollection::rul_replace_variable( $rul_user->rul_url, $user );
               			return $redirect_to;
           			}
        		}
    		}

    this part never gets true, it does not enter into loop.. so no redirects.

  11. drsim
    Member
    Posted 1 year ago #

    got it.. :)
    i have to use $user_has_groups[0]->grel_group_id not just group_id..

    thanks anyway ,, good piece of code ;)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic