Sunday, August 21, 2022
HomeWordPress Developmentphp - Replace consumer repeater meta (ACF) with one other consumer meta...

php – Replace consumer repeater meta (ACF) with one other consumer meta area worth


My objective is to get a signed-in consumer to pick a coloration (saved in ACF consumer meta area group) that will likely be utilized to a different consumer meta area inside a repeater. the sphere should be the identical for every row contained in the repeater ( for front-end design causes ). I’m utilizing ACF professional, and a plugin known as ACF Entrance finish admin (lets name it FEA any further) for the entrance finish kind. I am fairly new to PHP and have referenced ACF & FEA’s s documentation, which could be discovered under, to spin up a customized operate. I’m at present working this by code snippets plugin if this helps.

I am working the next code with no luck and would actually admire any assist!


    /// Hooks into any(?) kind and does one thing
add_action('acf_frontend/save_user', 'retrieve_colors_2_update', 10, 2);
operate retrieve_colors_2_update( $kind, $user_id ) {
    $consumer = get_user_by('ID',$user_id);
    //get essential fields
    $btn_color = get_field('button_color', 'user_' .$user_id);
    //// replace a repeater loop (ACF)
    if( have_rows('quick_link_selector', 'user_'.$user_id) ) {
        $i = 0;
        whereas( have_rows('quick_link_selector') ) {
            the_row();
            $i++;
            update_sub_field('repeater_button_color', $btn_color );
    }
}
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments