Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Create A Login Page That Redirects You Depending on Your Group

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1 2
Go to End
Author Topic: 9609 Views
  • Whizzle
    Avatar
    7 Posts

    Create A Login Page That Redirects You Depending on Your Group Link to this post

    Hey everyone... I'm pretty new but have figured out some things so far... But here is what I want to do... I want to create a HomePage (Via Tutorial) but with a twist... It will include the $loginForm but depending on what group you are affiliated I want it to redirect you to that page... I am using 2.1 for the new access tab.. Can anyone give me an code example to get me started?
    Thanks!

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Create A Login Page That Redirects You Depending on Your Group Link to this post

    Hey there,

    I've written up the basic idea here:

    http://doc.silverstripe.com/doku.php?id=overriding-loginform

    I hope this helps!

    Sean

  • Whizzle
    Avatar
    7 Posts

    Re: Create A Login Page That Redirects You Depending on Your Group Link to this post

    Looks good.... I messed with it after
    I got the reponse and had some issues not being able to log out and try another user... And it would not let me log out.... I was having some other issues so it could have been from it but could adding this do that too?

    Edit- Nevermind figured it out... But Can you give me some help on what to do in Redirectbygroup ?

    I added
    Director::redirect($groups[0]);

    But it didn't do anything... (Do I need to instatiate the custom form anywhere or does the code just replace the current login?
    trying to get the first group it gets but my PHP is on the noob level at best... I'm used to Java VB or LotusScript....

    Thanks!

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Create A Login Page That Redirects You Depending on Your Group Link to this post

    Hi Whizzle,

    I finished up the code found on this page:

    http://doc.silverstripe.com/doku.php?id=overriding-loginform

    It is a little limited in terms of a member being in multiple groups. However, it should work for a basic system.

    Let me know how you get on.

    Cheers,
    Sean

  • Whizzle
    Avatar
    7 Posts

    Re: Create A Login Page That Redirects You Depending on Your Group Link to this post

    Hi Sean.... I feel like an idiot but I can't seem to implement this... My question is do i need to instantiate this (ie add this to a page some how $loginform etc...) if so can you point me in the right direction... If not for some reason it's not working... I am going to www.foo.com/Security/login and logging in as a test id that is only a member of that group and it logs in just fine but no redirect... I went to the mysql admin and it shows that the group id is 3 and so that is what i put in the customlogin php file... I even put echo "<script>alert('yo')</script>" in the customlogin php file to see if it fires or not (not sure this would work or not but I don't know much about php debugging) and it doesn't seem to fire...\
    Thanks for all your help and I apologize for my noob-ness...

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Create A Login Page That Redirects You Depending on Your Group Link to this post

    Hi there,

    Have you ran ?flush=1 at the end of the URL after adding this new file? You need to do this, so that SilverStripe detects the new file and adds it to the class manifest. Also ensure you have Object::useCustomClass('LoginForm', 'CustomLoginForm'); in _config.php which will override any instantiations of LoginForm with your custom one.

    Also, please double check the classname is the same as the filename. eg. CustomLoginForm.php is 'class CustomLoginForm extends LoginForm', for example.

    I've tested this out and it seemed to work for me. It just might be that you simply need do ?flush=1 on your site.

    You could also try adding Debug::show('here'); somewhere in the PHP for the custom login form, so you can see if it's working or not.

    Cheers,
    Sean

  • Whizzle
    Avatar
    7 Posts

    Re: Create A Login Page That Redirects You Depending on Your Group Link to this post

    Here is my files and I'm getting nothing.... Thanks for your help

  • Whizzle
    Avatar
    7 Posts

    Re: Create A Login Page That Redirects You Depending on Your Group Link to this post

    Sorry here is my files

    9609 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.