Title: How to clone dynamically values
Last modified: December 28, 2020

---

# How to clone dynamically values

 *  Resolved [Mark](https://wordpress.org/support/users/brasiltemas/)
 * (@brasiltemas)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/how-to-clone-dynamically-values/)
 * 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](https://wordpress.org/support/users/brasiltemas/)
 * (@brasiltemas)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/how-to-clone-dynamically-values/#post-13841677)
 * Code I’m using to try add new IDs:
 * update_post_meta($post->ID ‘receive_notification’, $id);
 *  Plugin Support [longnguyen](https://wordpress.org/support/users/longnguyen/)
 * (@longnguyen)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/how-to-clone-dynamically-values/#post-13844219)
 * 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/](https://docs.metabox.io/fields/post/).
 *  Thread Starter [Mark](https://wordpress.org/support/users/brasiltemas/)
 * (@brasiltemas)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/how-to-clone-dynamically-values/#post-13845298)
 * 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](https://wordpress.org/support/users/longnguyen/)
 * (@longnguyen)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/how-to-clone-dynamically-values/#post-13848363)
 * Hi Mark,
 * You can use the function [update_post_meta()](https://developer.wordpress.org/reference/functions/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](https://wordpress.org/support/users/longnguyen/).

Viewing 4 replies - 1 through 4 (of 4 total)

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

 * ![](https://ps.w.org/meta-box/assets/icon-128x128.png?rev=1100915)
 * [Meta Box](https://wordpress.org/plugins/meta-box/)
 * [Support Threads](https://wordpress.org/support/plugin/meta-box/)
 * [Active Topics](https://wordpress.org/support/plugin/meta-box/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/meta-box/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/meta-box/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [longnguyen](https://wordpress.org/support/users/longnguyen/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/how-to-clone-dynamically-values/#post-13848363)
 * Status: resolved