We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36926
    • 701 Posts
    How does doodles popluate the createdby and editedby fields as I can't see where this is happening.

    I thought maybe this auto happened via the modObjectCreateProcessor but can't seem to get them to populate if I match the schema to doodles.

    Note i'm initially creating CMP using bxrextra generator for yoeman which doesn't created to those fields. So i'm amending the relevant files files to include them.

    This question has been answered by m.engel. See the first response.

      • 36926
      • 701 Posts
      Given up trying to suss out how this is getting auto populated within doodles example so i'm just setting within the create and update processors. In case it helps anyone else here's what i've added.

      $this->object->set('editedby',$this->modx->user->get('id'));
      
      $this->object->set('createdby',$this->modx->user->get('id'));
      
      • discuss.answer
        • 40706
        • 128 Posts
        Doodle has extended the xPDOObject below model/doodles/doodle.class.php

        public function save($cacheFlag = null) {
                /* set createdon/editedon */
                $now = new DateTime();
                $type = $this->isNew() ? 'created' : 'edited';
                $this->set($type.'on',$now->format('Y-m-d h:i:s'));
                if ($this->xpdo instanceof modX && $this->xpdo->user) {
                    $this->set($type.'by',$this->xpdo->user->get('id'));
                }
        
                return parent :: save($cacheFlag);
            }
          • 36926
          • 701 Posts
          Quote from: m.engel at Jun 11, 2015, 03:00 AM
          Doodle has extended the xPDOObject below model/doodles/doodle.class.php

          public function save($cacheFlag = null) {
                  /* set createdon/editedon */
                  $now = new DateTime();
                  $type = $this->isNew() ? 'created' : 'edited';
                  $this->set($type.'on',$now->format('Y-m-d h:i:s'));
                  if ($this->xpdo instanceof modX && $this->xpdo->user) {
                      $this->set($type.'by',$this->xpdo->user->get('id'));
                  }
          
                  return parent :: save($cacheFlag);
              }

          Awesome, thanks Michael.