Hello! First of all, I want to say a big thank you to all the forum participants and especially to those who help free of charge in studying and solving problems. You are best!
Now I will turn to my question:
On the page I have a lot of Flexible block with the same Layout, same fields, but different values in them
(Flex-Name: players)
(layout name: base)
-Flexible block
–Nick (text)
–Profile (text)
–uid (text)
–Result (repeater)
— R1 (text)
— R3 (text)
Flexible block is created after clicking the button in the Frontend ($ POST) and executing the code
$fields = get_fields ();
$field_key = "players"; // Flexible
$value = get_field ($ field_key);
$value [] = array (
"nick" => "$current_user-> user_firstname",
"profile" => "",
"uid" => "$current_user-> ID",
"result" => array (// repeater
array (
"R1" => "-",
"R2" => "-",
)
),
"acf_fc_layout" => "base"); // layout
update_sub_field ($ field_key, $value, $post_id);
update_field ($ field_key, $value, $post_id);
When the page is formed and all Flexible blocks are created, I need to update the value of only one Layout, which contains the value equal to “$ current_user-> ID” and replace it with another variable.
I have not been able to figure out on my own or find a solution on how to do this. All my attempts ended in nothing, or I completely demolished all the layout and left only one. I have read over 100 pages of forum, stackoverflow and Git.
This removes everything:
$flex_field_value = array (
array (
'acf_fc_layout' => 'base',
'field_60e4264fe03db' => 'value for sub field',
)
);
update_field ('field_60e4137bfc5ac', $flex_field_value, $post_id);
All I need is to find one specific value among all layers and replace it without erasing other fields and layers.
Thx for all.