Coding with SPIP 3.0
SPIP3.0 Technical Documentation

> > > > post_insertion

post_insertion

This pipeline is a trigger that runs after the insertion of new records into the database. This allows you to perform specific actions after record insertion.

The pipeline passes the name of the table, the identifier of the record created and an array of the fields and values inserted:

  1. pipeline('post_insertion',
  2. 'args' => array(
  3. 'table' => 'spip_articles',
  4. 'id_objet' => $id_article
  5. ),
  6. 'data' => $champs
  7. )
  8. );

Download

Example

Each new article that is created, automatically create a link to keyword 248:

  1. function ajoutmot_post_insertion($flux) {
  2. if ($flux['args']['table'] == 'spip_articles') {
  3. sql_insertq("spip_mots_articles", array(
  4. 'id_mot' => 248,
  5. 'id_article' =>$flux['args']['id_objet']));
  6. }
  7. return $flux;
  8. }

Download