When the post is saved, saves our custom data *
321315
function mf_save_post_data( $post_id ) {
    global $wpdb;

    //@todo hay que ponerle nonce a una de las metaboxes
    /*if ( !wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename(__FILE__) ) ) {*/
      //return $post_id;
    /*}*/

    if ( !current_user_can( 'edit_post', $post_id ) )
      return $post_id;

     //just in case if the post_id is a post revision and not the post inself
    if ( $the_post = wp_is_post_revision( $post_id ) ) {
      $post_id = $the_post;
    }

    // Check if the post_type has page attributes
    // if is the case is necessary need save the page_template
    if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != 'page' && isset($_REQUEST['page_template'])) {
      add_post_meta($post_id, '_wp_mf_page_template', $_POST['page_template'], true) or update_post_meta($post_id, '_wp_mf_page_template', $_POST['page_template']);
    }

    if (!empty($_POST['magicfields'])) {

      $customfields = $_POST['magicfields'];

      /** Deleting the old values **/
      $sql_delete = $wpdb->prepare( "DELETE FROM ".MF_TABLE_POST_META." WHERE post_id = %s",$post_id );
      $wpdb->query($sql_delete);

      foreach ( $customfields as $field_name => $field ) {
        delete_post_meta($post_id, $field_name);
      }
      /** / Deleting the old values **/

      //creating the new values
      foreach( $customfields as $field_name => $groups ) {

        $group_count = 1;
        foreach( $groups as $fields ) {
          $field_count = 1;
          foreach( $fields as $value ) {
            //here if the value of the field needs a process before to be saved
            //should be trigger that method here
            //$value =  mf_process_value_by_type($field_name,$value);

            // Adding field value meta data
            add_post_meta($post_id, "{$field_name}", $value);

            $meta_id = $wpdb->insert_id;

            $sql_insert = $wpdb->prepare(
              "INSERT INTO " . MF_TABLE_POST_META .
              " ( meta_id, field_name, field_count, group_count, post_id ) " .
              " VALUES " .
              " (%s,'%s',%s,%s,%s) ",
              $meta_id,
              $field_name,
              $field_count,
              $group_count,
              $post_id
            );

            $wpdb->query($sql_insert);

            $field_count++;
          }
          $group_count++;
        }
      }
    }
  }
145946
public function save()
    {
        if ($this->_state == CRUD::CREATE_STAT) {
            $this->add();
        } elseif ($this->_state == CRUD::UPDATE_STAT) {
            $this->edit();
        }
    }
1230989
public function loadPOST()
    {
        $post = $_POST;

        $this->hook('loadPOST', [&$post]);
        $errors = [];

        foreach ($this->fields as $key => $field) {
            try {
                $value = isset($post[$key]) ? $post[$key] : null;

                // save field value only if field was editable in form at all
                if (!$field->readonly && !$field->disabled) {
                    $this->model[$key] = $this->app->ui_persistence->typecastLoadField($field->field, $value);
                }
            } catch (\atk4\core\Exception $e) {
                $errors[$key] = $e->getMessage();
            }
        }

        if ($errors) {
            throw new \atk4\data\ValidationException($errors);
        }
    }
1326373
protected function saveData()
    {
        parent::saveData();

        if ($this->createData && (! $this->roundId)) {
            $this->roundId = $this->formData['gro_id_round'];
        }


        if ($this->formData['gro_valid_for_source'] == 'tok'
         && $this->formData['gro_valid_for_field']  == 'gto_valid_from'
         && empty($this->formData['gro_valid_for_id'])) {
            // Special case we should insert the current roundID here
            $this->formData['gro_valid_for_id'] = $this->roundId;

            // Now save, don't call saveData again to keep changed message as is
            $model          = $this->getModel();
            $this->formData = $model->save($this->formData);
        }

        $this->trackEngine->updateRoundCount($this->loader->getCurrentUser()->getUserId());
    }
1098200
public function onAfterWrite()
    {
        parent::onAfterWrite();

        if ($this->Customisation) {
            $data = unserialize($this->Customisation);

            if ($data instanceof ArrayList) {
                foreach ($data as $data_item) {
                    $data_item->ParentID = $this->ID;
                    $data_item->write();
                }

                $this->Customisation = null;
                $this->write();
            }
        }
    }
489737
public function save()
	{
		if (self::$file_added)
			file_put_contents($this->getFileListName(), '<?php return ' . var_export(self::$files[$this->prefix], true) . ';');

		self::$file_added = false;
	}
441761
function save(callback) {
            var model, request;

            model = this;

            this.constructor.dispatch('beforeSave', {
                data : {
                    model : this
                }
            });
            this.dispatch('beforeSave');

            this.isValid(function (isValid) {
                if (isValid) {
                    if (model.hasOwnProperty('id') && model.id !== '') {
                        request = {
                            action : 'update',
                            data : model,
                            model : model.constructor
                        };
                        model.constructor.storage.update(request, function updateCallback(data) {
                            model.constructor.dispatch('afterSave', {
                                data : {
                                    model : model
                                }
                            });

                            model.dispatch('afterSave');
                            if (callback) {
                                callback(data);
                            }
                        });
                    }
                    else {
                        request = {
                            action : 'create',
                            data : model,
                            model : model.constructor
                        };
                        model.constructor.storage.create(request, function createCallback(data) {
                            model.constructor.dispatch('afterSave', {
                                data : {
                                    model : model
                                }
                            });

                            model.dispatch('afterSave');
                            if (callback) {
                                callback(data);
                            }
                        });
                    }
                } else {
                    if (callback) {
                        callback(data);
                    }
                }
            });

        }
27256
protected function saveData()
    {
        if ($this->trackEngine) {
            // concatenate user input (gtf_field fields)
            // before the data is saved (the fields them
            $this->formData['gr2t_track_info'] = $this->trackEngine->calculateFieldsInfo($this->formData);
        }

        // Perform the save
        $model          = $this->getModel();
        $this->formData = $model->save($this->formData);
        $changed        = $model->getChanged();
        $refresh        = false;

        // Retrieve the key if just created
        if ($this->createData) {
            $this->respondentTrackId = $this->formData['gr2t_id_respondent_track'];
            $this->respondentTrack   = $this->loader->getTracker()->getRespondentTrack($this->formData);
            
            // Explicitly save the fields as the transformer in the model only handles
            // before save event (like default values) for existing respondenttracks
            $this->respondentTrack->setFieldData($this->formData);

            // Create the actual tokens!!!!
            $this->trackEngine->checkRoundsFor($this->respondentTrack, $this->userId);
            $refresh = true;

        } else {
            // Check if the input has changed, i.e. one of the dates may have changed
            $refresh = (boolean) $changed;
        }

        if ($refresh) {
            // Perform a refresh from the database, to avoid date trouble
            $this->respondentTrack->refresh();
            $this->respondentTrack->checkTrackTokens($this->userId);
        }


        // Communicate with the user
        $this->afterSave($changed);
    }
1273442
public function postSave()
    {

        // check if the model already exists
        if ((!isset($this->revisionEnabled) || $this->revisionEnabled) && $this->updating) {
            // if it does, it means we're updating

            $changes_to_record = $this->changedRevisionableFields();

            $revisions = array();

            foreach ($changes_to_record as $key => $change) {
                $revisions[] = array(
                    'revisionable_type'     => $this->getMorphClass(),
                    'revisionable_id'       => $this->getKey(),
                    'key'                   => $key,
                    'old_value'             => array_get($this->originalData, $key),
                    'new_value'             => $this->updatedData[$key],
                    'user_id'               => $this->getSystemUserId(),
                    'created_at'            => new \DateTime(),
                    'updated_at'            => new \DateTime(),
                );
            }

            if (count($revisions) > 0) {
                $revision = static::newModel();
                \DB::table($revision->getTable())->insert($revisions);
            }
        }
    }
40511
public function save()
	{
		if ( ! $this->is_loaded() ) return false;

		$this->fill_defaults();

		$error = null;

		$id = wp_insert_post( $this->attributes, $error );

		if ( ! empty( $id ) ) {

			$this->attributes['ID'] = $id;

			$this->save_meta_all();

		}

		return $error === false ? true : $error;
	}
832384
protected function saveData()
    {
        parent::saveData();

        $this->user->setPasswordResetRequired(false);
        $this->loginStatusTracker->setPasswordResetActive(false);
    }
885939
function save() {
    // we must reset the colour cache or it will keep bad colours after clipping
    $this->currentColour = null;
    $this->currentStrokeColour = null;
    $this->objects[$this->currentContents]['c'].=  "\nq";
  }
163839
def save
      if loaded?
        self.class.update(@fields.format_for_update, jira_key)
      else
        response = self.class.create(@fields.format_for_create)
        self.jira_key = response.parsed_response["key"]
      end
      jira_key
    end
764690
def saveCustomData(self, data):
        
        LOGGER.info('Sending customData to Polyglot.')
        message = { 'customdata': data }
        self.send(message)
653843
function save() {
          $.jsonCall('/apos-pages/' + action,
            data,
            function(data) {
              apos.redirect(data.slug);
            },
            function() {
              alert('Server error');
              callback('Server error');
            }
          );
        }
512317
def post_save(self):
        """"""
        if self.run:
            self.run = False
            self.create_tasks()
            self.save()
250051
def save(self, commit=True, **kwargs):
        
        if self.post:
            for form in self.forms:
                form.instance.post = self.post
        super().save(commit)