Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

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

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

Create A Login Page That Redirects You Depending on Your Group


Go to End
Reply


9 Posts   9832 Views

Avatar
Whizzle

7 Posts

12 August 2007 at 8:36am

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!

Avatar
Sean

Forum Moderator, 922 Posts

12 August 2007 at 12:39pm

Hey there,

I've written up the basic idea here:

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

I hope this helps!

Sean

Avatar
Whizzle

7 Posts

14 August 2007 at 4:13am

Edited: 14/08/2007 12:51pm

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!

Avatar
Sean

Forum Moderator, 922 Posts

14 August 2007 at 6:37pm

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

Avatar
Whizzle

7 Posts

2 September 2007 at 7:46am

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

Avatar
Sean

Forum Moderator, 922 Posts

2 September 2007 at 2:18pm

Edited: 02/09/2007 2:20pm

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

Avatar
Whizzle

7 Posts

3 September 2007 at 2:50am

Edited: 03/09/2007 2:50am

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

Avatar
Whizzle

7 Posts

3 September 2007 at 2:51am

Sorry here is my files

Go to Top