• Resolved Zatsugami

    (@zatsugami)


    Hello,

    I’ve noticed a weird behavior of WordPress when visiting Posts > Add New.
    It auto inserts drafts every time i refresh the page. I end up having database filled up with unwanted, unused post data. Is this normal?

    I’ve noticed this while developing some plugin which needs to take an action in time when NEW post is inserted and insert its own data.
    I don’t want to fill the database with additional data that is related to unused posts.

    Where I’m trying to hook up is save_post action. I have a problem determining if the action is taking place when post is updated or when new post is inserted.

    Basically, I need to hook up somewhere to take action just when there is a data insertion (but not empty post) and when the post is updated.
    And I need access to post data, not just ID.

    I’m confused because there is more than one function which could do the job, but neither does it the way I want it (probably).

    Thanks,

    Sylwester

Viewing 3 replies - 1 through 3 (of 3 total)
  • Have you tried using a “filter” hook instead of an “action” hook in that line of code in your plugin?

    Thread Starter Zatsugami

    (@zatsugami)

    I’ve looked through all the filters in the documentation and I didn’t noticed anything useful for this. Maybe I’ve omitted something.
    I need to have access to all post data in one time, not just content or ID or title and so on.

    I can hook up to edit_post or post_updated action probably, but this doesn’t help with data insertion.

    EDIT:
    Maybe I could use POST_ID to get post by get_post function, but it would be option only if there is no database call.

    Thread Starter Zatsugami

    (@zatsugami)

    I forgot about 4rd parameter in add_action indicating number of arguments.
    This way I can get access to the data I need. Proper if statements should do the job.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Drat auto database insertion on refresh’ is closed to new replies.