• Resolved Begin

    (@bentalgad)


    I have a repeatable group and 3 sub fields inside.

    for example (just explaining the format here for the question:
    <my_group_field>
    <first_field><second_field><third_field>
    </my_group_field>

    And how would i update the value of one fields in existing group?

    Thanks!

    • This topic was modified 7 years, 3 months ago by Begin.
    • This topic was modified 7 years, 3 months ago by Begin.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Begin

    (@bentalgad)

    I found this solution:

    $my_group = get_post_meta( '839', 'pro_paypal_kidum', true );
    $key = array_search('95.00', array_column($my_group, 'price'));
    $my_group[$key][state] = 'active';
    update_post_meta( '839', 'pro_paypal_kidum', $my_group );

    Do you think there’s a better one?

    Plugin Author Justin Sternberg

    (@jtsternberg)

    That is a decent way to handle it, but [state] should be ['state'] or you’ll get notices in the log.

    Thread Starter Begin

    (@bentalgad)

    Great! Thanks!

    • This reply was modified 7 years, 3 months ago by Begin.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do i update a sub field using php?’ is closed to new replies.