Custom Fields
Re-Envisioned
Support MB Revision update_post_meta does not add new revision

This topic contains 1 reply, has 2 voices, and was last updated by  Anh Tran 4 months, 3 weeks ago.

  • Creator
    Topic
  • #14973

    raphael
    Participant

    Hello,
    I’ve enabled MB Revision and it works great when I update a custom field through the admin panel but when I do it programmatically through update_post_meta, the change is not detected so there is no revision added.

    Is it Work As Intended ? Is there another utility function that would trigger the creation of a revision ? Another way to trigger it manually ?

    Thanks !

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #15014

    Anh Tran
    Keymaster

    Hi raphael,

    The update_post_meta is the low level API for adding post meta, while the revision stays in higher level of the WordPress app. So, if you use update_post_meta, that’s the expected behavior.

    I think trigger the creation of a revision can be done with wp_insert_post. Here is the docs for it: https://wordpress.org/support/article/revisions/#revision-storage-method. Strangely, I couldn’t find a programmatic way to create a revision. Probably WordPress doesn’t support it yet.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.