WordPress.org

Forums

Front-end Editor
[resolved] save_post equivalent when saving a field (5 posts)

  1. morfie
    Member
    Posted 12 months ago #

    I have a custom 'save_post' action defined in my functions.php which checks the value of a certain post_meta field and based on that value, updates a different post_meta field. This works all nice and happy.
    I am using editable_post_meta() for the post_meta field that needs to be checked. Obviously, when just this one field is saved, it doesn't trigger the 'save_post' action... I'm not saving the whole post, just this field.
    Is there a way to trigger a wordpress action or php function when just that field is saved? Is there a custom action ('save_meta') or something that I can do that will be triggered when this field is updated?
    Thanks.

    https://wordpress.org/plugins/front-end-editor/

  2. morfie
    Member
    Posted 12 months ago #

    Nevermind. I discovered the 'updated_post_meta' action. All good!

  3. morfie
    Member
    Posted 12 months ago #

    For those of you interested

    function functionname($meta_id, $post_id, $meta_key, $meta_value) {
      ...
    }
    add_action( 'updated_post_meta', 'functionname', 10, 4 );
  4. Frankie Jarrett
    Member
    Posted 2 weeks ago #

    I think you have a slight misspelling in your hook name.

    It should be updated_postmeta as defined in core here.

  5. Frankie Jarrett
    Member
    Posted 2 weeks ago #

Reply

You must log in to post.

About this Plugin

  • Front-end Editor
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic