Forum Replies Created

  • Thank you, I did end up using integers in my ultimate solution. However, I couldn’t get add_row to work, my ultimate solution was the following:

    function assign_internal_writer_callback($request)
        $parameters = $request->get_params();
        $outline_task = $parameters['outline_task']; //ID for Task associated with Stage Two
        $write_task = $parameters['write_task']; //ID for Task associated with Stage Five
        $user = $parameters['user']; //User ID
        $project_set = $parameters['project_set']; //Project Set ID
        if ($outline_task != '' && $write_task != '' && $user != '' && $project_set != '') {
            update_post_meta($outline_task, 'user', $user);
            update_post_meta($write_task, 'user', $user);
            $team_size = get_term_meta($project_set, 'project_set_campaign_team');
            $new_team_size = strval(intval($team_size[0] + 1)); 
            //Need to follow this convention for field keys in order for them to display in UI
            $user_field_key = '_project_set_campaign_team_' . $team_size[0] . '_user';
            $role_field_key = '_project_set_campaign_team_' . $team_size[0] . '_role';
            $user_key = 'project_set_campaign_team_' . $team_size[0] . '_user';
            $role_key = 'project_set_campaign_team_' . $team_size[0] . '_role';
            update_term_meta($project_set, 'project_set_campaign_team', $new_team_size); //This meta field holds the number of rows in the repeater, needs to be updated +1 to display in UI
            update_term_meta($project_set, $role_key, 268);
            update_term_meta($project_set, $role_field_key, 'field_5faa2bce9fe7c');
            update_term_meta($project_set, $user_key, intval($user));
            update_term_meta($project_set, $user_field_key, 'field_5faa2c0b9fe7d');
            return get_term_meta($project_set);
        } else {
            return 'Please supply the correct request parameters: Outline Task ID, Write Task ID, Project Set ID and User ID';

    I’ve had several issues where I tried to use ACF methods like update_field and add_row to solve a problem, and they weren’t working. I was able to update with native WP methods like update_post_meta and update_term_meta. Is there any reason I’m unaware of not to do this?

  • Actually my mistake was this was not a repeater field. What I ended up doing was

    update_post_meta($project, ‘project_type_content_content_external_writer’, $writer);

    Which appears to work fine.

Viewing 2 posts - 1 through 2 (of 2 total)