Skip to content

How can I update cloneable field values? #138

@MrJoshFisher

Description

@MrJoshFisher

Hello,

I'm having an issue with trying to update the values of a cloneable field, for instance,

Retrieving the value as follows
$emails = get_post_meta(123, 'memo_category-103');

print_r($emails); as you'd expect returns
Array ( [0] => test2@test2.com [1] => test@test.com )

I can array push to add a new value:

array_push($emails, 'test3@test3.com');
Array ( [0] => test2@test2.com [1] => test@test.com  [2] => test3@test3.com );

But when I save it for example

$emails = array('test2@test2.com', 'test@test.com', ' test3@test3.com');
update_post_meta(123, 'memo_category-103', $emails);

I get this
Array ( [0] => Array ( [0] => test2@test2.com [1] => test@test.com [2] => test3@test3.com ) [1] => Array ( [0] => test2@test2.com [1] => test@test.com [2] => test3@test3.com ) )

I've tried several different ways to try and rectify this but it doesn't work, I would love to switch to a different meta field plugin but unfortunately, I can't as there are thousands of posts stored using this so I'm having to try my best to rectify it, any help would be greatly appreciated.

Or if anyone else has a solution it too would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions