Hello,

I want to set up login direction to send specific roles to specific pages upon login.

I know that i need to create php snippets to do this but am not smart enough to work this out for myself. I have searched the forum and tried copying and pasting various snippets but i suspect i am doing something fundamentally wrong.

Can anyone spell it out and help me with some generic code?

Thanks

Comments

perfectmatch’s picture

Doh .... knew if i read the forum long enough i'd find the answer ......

  global $user;

  if (in_array('role1', $user->roles)) {

    // Redirect users will role1 role
    return 'role1-url';

  } elseif (in_array('role2', $user->roles)) {

    // Redirect users will role2 role
    return 'role2-url';

  } else {
    return 'default-url';
  }

Hope this helps someone else ....

adrianrf@gmail.com’s picture

cheers,

Adrian
Adrian Russell-Falla