• Resolved Jeman_wp

    (@jeman_wp)


    Hi all
    I developed a plugin which introduces new custom fields to the edit post panel. When a post is submitted my plugin checks this fields. This is the problem: I’d like not to proceed with the updating or saving post when wp finds errors in this custom fields. When it finds errors it doesn’t process the fields but still goes on to update/save the post.
    How can I handle this?

    Thank you all!

Viewing 4 replies - 1 through 4 (of 4 total)
  • There is no core functionality for this.

    You could add a check for your compulsory fields and write a div with class error (if I remember correctly) warning the user of the missing fields. WordPress will float this to the top of the page with a red background colour.

    On the front end you can filter the results to make sure they have the required fields and then not display them if they are missing.

    Thread Starter Jeman_wp

    (@jeman_wp)

    Thanks TCBarret, that’s a good one.
    So wordpress doesn’t provide anything to stop processing…which it sounds quite right if the brawser calls the server side, but i can still think there could be a way to do that.
    Anyway, thank you again!

    Well, you can hook into something like the save_post filter and call wp_die(), which would give quite an abrupt experience for the user.

    However, you would need to look into all the possible hooks called (like bulk and auto saving scenarios). There might be others. It gets comparatively complex and I would worry about it being easily compatible with future version releases.

    Thread Starter Jeman_wp

    (@jeman_wp)

    You are probably right. I think i’m gonna take good your first suggestion.
    Just by curiosity i’m gonna take a quick look at the things that you’ve just said.

    Thank you so much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘do not allow wp to publish/update post when it finds errors’ is closed to new replies.