Home Forums Add-ons Repeater Field Moving Repeater Field Values from another Repeater Field and vice versa


Moving Repeater Field Values from another Repeater Field and vice versa

  • Hi!

    I just want to ask if this is possible.

    I plan to create 2 option page with same fields of Repeater. I just want to ask if is it possible if I can create a toggle on Option Page 2 where when I clicked , “Move to Option Page 1”, all the value from the Option Page 2 will be move to Option Page 1 repeater fields or vice versa?

    Thanks guys!

  • First of all, you cannot just create 2 options pages with the same fields. If the fields are named the same then they will actually be the same fields. Any update on one options page will update the other options page as well. Using the default post_id of “options” all values are stored in the options table with the field names you use.

    There are 2 choices for a solution to the above. The first is to use different field names for each options page and the second is to use different post ID values for each options page.

    Second, is it possible to move them? You’d have to create some type of a field to indicate that they will be moved. Then you will need to create an acf/save_post action to do the work.

    With that solved then, yes it would be possible.
    For the most part all I can do is give you pseudocode.

    add_action('acf/save_post', 'move_values', 20);
    function move_values($post_id') {
      // check post id to see if it is one of your options pages if not then return
      // see if values should be moved, if not then return
      // test to see which page is being saved
      // get the values from the options page being updated
      // update the fields on the options page you want to move them to
      // delete the values from the options page being saved
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.