callback function

Support General callback function

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #48874
    jw_blnjw_bln
    Participant

    Say I have a select field, but want to use a callback function to fill the options.
    The data are stored in a cloneable group in another custom field.
    I do not need any live changes; getting the select-data (callback) only on page load is okay.

    There are different support posts, explaining that it is not intended or that a certain order needs to be incorporated.

    So, please, can you provide one or two examples of how to achieve such a callback function on a select field coming from another cloeanable group field?
    Thanks.

    #48898
    PeterPeter
    Moderator

    Hello,

    Thanks for reaching out.

    I'm afraid that supporting the customization code is beyond our scope of support. However, I think there are 2 notes that you may need to follow:
    - the callback function should return an array of values and labels:

    function callback_func() {
        return [
            'red'       => 'Red',
            'green'     => 'Green',
            'blue'      => 'Blue'
    
        ];
    }

    - use the get_post_meta() function to get the field value in the callback function.

    Refer to this topic https://support.metabox.io/topic/select-function-callback/#post-48783

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