• Resolved Mark

    (@brasiltemas)


    Hello,

    I need to store IDs in a custom field and return it in an array, ex: array (4, 22, 97, 1).

    How is the best method to do it?

    I’m trying to do it with text type and clone = true but I don’t know how to add values dynamically with a php function.

    array(
    ‘id’ => ‘receive_notification’,
    ‘name’ => ‘Notifications’,
    ‘type’ => ‘text’,
    ‘clone’ => true
    ),

    Can anyone help me? Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Mark

    (@brasiltemas)

    Code I’m using to try add new IDs:

    update_post_meta($post->ID ‘receive_notification’, $id);

    Plugin Support longnguyen

    (@longnguyen)

    Hi Mark,

    The field post will help you to save the post IDs as the post meta. Get more details in the documentation https://docs.metabox.io/fields/post/.

    Thread Starter Mark

    (@brasiltemas)

    Hello Long,

    Thanks for your response! I do it:

    array(
    ‘id’ => ‘receber_notificacoes’,
    ‘name’ => ‘Notificações’,
    ‘type’ => ‘user’,
    ‘clone’ => true
    ),

    It works fine in the front-end, but I need to add new users IDs through a PHP function, how could I do that?

    Thanks!

    Plugin Support longnguyen

    (@longnguyen)

    Hi Mark,

    You can use the function update_post_meta() to add new users ID to the post meta receber_notificacoes.

    update_post_meta( $post_id, 'receber_notificacoes', array( 1, 2, 3 ) )

    • This reply was modified 5 years, 5 months ago by longnguyen.
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘How to clone dynamically values’ is closed to new replies.