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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Add name of member who uploaded file to file object


Go to End


4 Posts   1163 Views

Avatar
Howard

Community Member, 215 Posts

9 June 2009 at 6:54pm

Hi guys,

I am using the FileDataObjectManager to upload documents but wondered how to record the name of the user who uploads the file into the data object. I can do this using a front end form by doing something similar to this:

In the form submit function:
$member = Member::currentUser();
$firstname = $member->FirstName;
$lastname = $member->Surname;
$image->UploadMember = $firstname . " " . $lastname;

But I'm no sure how to do it with the objectmanager. Any ideas? Thanks

Avatar
UncleCheese

Forum Moderator, 4102 Posts

10 June 2009 at 3:12am

Good idea. Put it in Feature Requests.

Avatar
Howard

Community Member, 215 Posts

10 June 2009 at 11:44am

Hey UncleCheese, I'm not sure if is worth putting it in as a feature request as it is actually super easy to do - I just added this to my dataobject class:

	public function populateDefaults(){
   		parent::populateDefaults();
   		
   		$Name = Member::currentUser();
		$firstName = $Name->FirstName;
		$lastName = $Name->Surname;

    	$this->UploadMember = $firstName.' '.$lastName;
 	}

Might be useful for someone else :)

Avatar
UncleCheese

Forum Moderator, 4102 Posts

10 June 2009 at 1:58pm

Yeah, but it should do that out of the box. Every other file upload interface in SS does it.