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:

pipeline('post_insertion',
	array(
		'args' => array(
			'table' => 'spip_articles',
			'id_objet' => $id_article
		),
		'data' => $champs
	)
);

Example

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

function ajoutmot_post_insertion($flux) {
	if ($flux['args']['table'] == 'spip_articles') {
		sql_insertq("spip_mots_articles", array(
			'id_mot' => 248,
			'id_article' =>$flux['args']['id_objet']));
	}
	return $flux;
}

Author Mark Baber Published : Updated : 12/03/23

Translations : English, français