Set field value automatically

Support General Set field value automatically

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #41419
    Trang NguyenTrang Nguyen
    Participant

    Hi! I'm using custom table to store the fields data.

    To make it easy to manage on PHPMyAdmin, I would like to create a text field (name_cb) to store the same value as the post title.

    How can I set the value of the name_cb field automatically when I create/edit a post? If I change the post title, the value of this field will be updated to it also.

    Thank you!

    #41431
    PeterPeter
    Moderator

    Hello,

    You can use the function \MetaBox\CustomTable\API::add() or \MetaBox\CustomTable\API::update() and hook to the action save_post to update a field in a custom table automatically. Please read more on these documents
    https://developer.wordpress.org/reference/hooks/save_post/
    https://docs.metabox.io/extensions/mb-custom-table/#add

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.