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.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Member Login

Go to End

11 Posts   10543 Views

Juerg Sommer

Community Member, 2 Posts

30 December 2008 at 9:18am


I started with SilverStripe two days ago and the system works - the greatest CMS I've seen. Very good to customize and good tutorial.

Now I'm configuring the member section: the pages works well and also the login works fine, but there's no tutorial about this section (or I didn't find it).

My Problem is the "status" of the user (and his name/profile). What I would is an information on each page like this forum

"You're logged in as {firstname} {lastname} | Log Out | Profile"

But how can I know if a user's logged in (and with what loginname, firstname, lastname, ...), so that I can display these informations in the layout-template?

I also want to change the login-form, is there a better way than modify the MemberLoginForm.php? (there are layout-changes, textes I could change in the language-folder).

Last Question: is there an existing "user-profile" page I could modify for my users or have I to build a own one (wouldn't be a problem, if I know where I can get the user informations).

Thanks a lot for every answer!


Carbon Crayon

Community Member, 598 Posts

30 December 2008 at 10:40am

Edited: 30/12/2008 10:49am

Hi Juerg, welcome to silverstripe :)

Firstly, accessing the current member is easy.

In the controller (or model) something like:

if($member = member::currentUser()){
return $member.FirstName;

Or in the template you can use something like:

<% if CurrentMember %>
<p>Logged in as: $CurrentMember.FirstName </p>
<% end_if %>

To change the login form you can extend the MemberLoginForm class. To do this create a file called CustomLoginForm.php in your mysite/code folder and put something like:

class CustomLoginForm extends MemberLoginForm {

	public function dologin($data) {
                        [some code]


Then in your _config.php file you can specify that you want SS to use your custom class in place of teh standard login by adding this line:

Object::useCustomClass('MemberLoginForm', 'CustomLoginForm');

This also ensures that if you upgrade your SS version you wont have to worry about overwriting your changes.

As for your final question I am not entirely sure, I don't think there is an actual member page, but you can easily create one using the currentMember functions above. for reference look at the forum module which does have a member profile page and also adds a load of fields (Nickname, occupation, country etc). if you are going to add fields to teh member class then I think the best way to do it is using the data object decorator, but someone else may be able to give you more info on that as I have not actually used them yet.

Anyway hope that gets you someway to where you want to be :)


Juerg Sommer

Community Member, 2 Posts

30 December 2008 at 12:09pm

Hi Aram

Thanks for your very fast und informative answer. I'll try it and I'm sure this will solve my problem.



Community Member, 2 Posts

10 January 2009 at 6:41am

Silverstripe is way beyond the competition. Thanks for the post, I am also looking for a solution to this problem.


Carbon Crayon

Community Member, 598 Posts

10 January 2009 at 7:15am

Your welcome :) And yes, it's fabulous ins't it!


Community Member, 2 Posts

13 January 2009 at 10:13am

Absolute Fabulous! Elegant!

Silverstripe has helped me beat the deadline not only for 1 website but 2 and impressed both clients at the same time. It could have been a disaster if I haven't found Silverstripe.


Community Member, 165 Posts

13 June 2009 at 4:18am

I am also wanting to create a custom login however I don't want to replace the current MemberLogin Class I want to have two different login forms. The current MemberLogin Form that allows logging into the CMS Admin section would stay the same but I want a login for a front end public members section on a different page. The difference between my Member Login and Admin Login is the page the member gets redirected to.

I have tried making my own Authenticator by extending Authenticator just like MemberAuthenticator and registering it using Authenticator::register_authenticator(); in my _config.php, then I added my own LoginForm() function to my page controller like this:

public function LoginForm(){
$authenticator = 'CustomAuthenticator';
$authenticators = Authenticator::get_authenticators();
if(in_array($authenticator, $authenticators)) {
return call_user_func(array($authenticator, 'get_login_form'), $this);

However when I look at the generated form the Action is always MemberAuthenticator so it doesn't seem to work.

Any help or tips on how this all works would be appreciated.


Community Member, 14 Posts

14 June 2009 at 1:12am

micahsheets, this tutorial may be useful for you :

Go to Top