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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Save the member on editing a dataobject


Go to End


3 Posts   895 Views

Avatar
Pipifix

Community Member, 56 Posts

1 March 2012 at 3:24am

Edited: 01/03/2012 3:34am

Hi and Hello.

I've got a dataobject (projects) on a webpage. And there are a bunch of editors allowed to edit this dataobjects. My client want to see, which single dataobject item is edited by which editor (currentMember). So what i need is a startingpoint (or a simple tutorial) to get this problem solved.
It is neccesary to use a hook like onBeforeWrite()? Is there something like "lasteditedby"?

I guess its a simple task but i dont got a clue where to start. Thanks a lot, Pipifix

Avatar
danzzz

Community Member, 175 Posts

1 March 2012 at 6:39am

hi

you can add a new field to the dataobject, for example "lasteditby"

and then set a value for it with onBeforeWrite()



function onBeforeWrite() {
	
if( $member = Member::currentUser() ) {
   $this->lasteditby = $member->ID;
} 
	
parent::onBeforeWrite();


}

dont tested this, but should point to right direction...

Avatar
Pipifix

Community Member, 56 Posts

1 March 2012 at 10:59pm

Hi danzzz

Thanks for your response. I'll give it a try.
Pipifix