Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Add name of member who uploaded file to file object

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 755 Views
  • Howard
    Avatar
    Community Member
    215 Posts

    Add name of member who uploaded file to file object Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Add name of member who uploaded file to file object Link to this post

    Good idea. Put it in Feature Requests.

  • Howard
    Avatar
    Community Member
    215 Posts

    Re: Add name of member who uploaded file to file object Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Add name of member who uploaded file to file object Link to this post

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

    755 Views
Page: 1
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.