action save_post not firing on create post (4 posts)

  1. PatJ
    Posted 4 years ago #

    save_post hook

    I'm writin a plugin which uses custom post types and I've added

    function ddb_custom_post_format_admin() {
    add_action('save_post', 'ddb_save_data');


    function ddb_save_data($post_id) {
    // try echoing to see what we have
    	echo 'ddb_save_data-post type=' . get_post_type();

    This works perfectly if I am editing but it doesn't seem to fire at all when adding from the "Add new" menu item of the custom post type.
    The new post of custom post type saves and can be edited OK
    but how can I hook into the save_post of a new post?
    I want to hook into it straight after it has saved so I can do other processing.

    Am I adding the action in the right place?

  2. guldi
    Posted 4 years ago #

    try publish_post

  3. guldi
    Posted 4 years ago #

  4. PatJ
    Posted 4 years ago #

    Sorted - save_post was firing but the $post variable is not set so a null string was being output. Taking out the bloat and going back to basics sorted it.

Topic Closed

This topic has been closed to new replies.

About this Topic