Closed jlambe closed 9 years ago
2 new hooks for custom post type:
Action::add('themosis_postTypeName_BeforeSave')
Action::add('themosis_postTypeName_AfterSave')
Both actions will pass 3 arguments:
So if we have a custom post type with a name of prefix-cars
:
$cars = PostType::make('prefix-cars', 'Cars', 'Car')->set();
// Run code just before saving car post type data.
Action::add('themosis_'.$cars->get('name').'_BeforeSave', 'CarsController@before');
// Run code right after saving car post type data.
Action::add('themosis_'.$cars->get('name').'_AfterSave', 'CarsController@after');
This is going to be removed finally as there is already by default a save_post_{$post_type}
action hook available by WordPress.
As there is no access to each post type save_post action function, provide a hook for each custom post type so developers can run custom code when publishing/updating a post.