Support

Account

Forum Replies Created

  • I have tried your methods, and they didn’t resolve this issue. And the fields are populating, because when I go the back end, they are there. I appreciate your time and effort John, I really do. I’ll probably submit a ticket like you suggest.

    In the meantime I have figured out a temporary solution. Instead of attaching the calculations to run during the save process (acf/save_post) I have just place a call to the function right in my template at the top of the page. This is giving me the results I had expected – the function runs, updates fields, then the page loads, where I can use get_field to display the results of the calculations.

  • When I open the frontend page with the ACF Form, then click the submit button, a new post is created. If I go on the backend to that post, there are ACF fields with data copied over to them the way I would expect. This part is all fine and good. I tried the two suggestions you made, and there was no difference between the the results of what I was doing and the two methods you suggested, unfortunately.

    I’m not sure if I’m being really dense and not getting your point, but I’ve been through the forums and resources 100x times, I could recite the content of the acf/save_post and update_field.

    During the “saving” process, the fields I copy over (via the first block of code in the first post) are not accessible to the code in the second set of code; however after the “saving” process is completed and the page loads up, the fields are there. I’m trying to understand why the calculations actions that are scheduled (priority 50) to occur after the fields are filled in (priority 30) aren’t working. I either need to figure out why the priorities aren’t working like I’d expect, or an action to execute after a post save, or a hack to force the post to save twice.

  • Is the first option a more manual version of the second one, I didn’t quite follow where you were going with it.

    As for the second one, it is very close to what I had, but with some better checks and using acf_get_fields, instead of get_fields. What is the reasoning behind this, won’t get fields work just as well?

    I have 4 acf groups and I include them in acf_form from the beginning:

    
    /* Create Front-End Form */ 
    global $current_user; //get current logged in user info
    $author_id = $current_user->ID; //pull user id and assign to author_id variable
    					
    //form/post options
    $args = array( 
    'post_id'	=> 	'new_post', //creates new post instead of editing 																										
    'field_groups' 	=>	array(79,359,1877,1966), //proposal field group
    'return'        =>	'%post_url%', // redirect to new post url
    'new_post'	=> 	array( //option for new post
        'post_type'	=> 	'proposals', //creates a new post in "Proposals" CPT
        'post_status'	=> 	'draft', //
        'post_author'	=>	$author_id //assigns author as the person logged in
    			),
    'submit_value'	=> 'Create Proposal'
    );
    							
    //loads the ACF fields with above settings
    acf_form( $args ); 
    

    I tried the second option, but I got the same outcome. All of the fields populate on creation except for the calculations, since they can’t get the values for the other fields.

  • On the backend of the site we have ACF Fields/Groups, and the groups are assigned to show on these posts. The fields have no default value defined in ACF, we define the values by the first code block, which copies the data from an options page and the author page. We do this because each post needs to stay the same in the future, even if the data on the options page changes.

    The issue occurs when making a new post (either through the backend or acf_form frontend). So we don’t manually input any data in these fields, but they are updated programmatically when creating the post. I am already defining each variable with get_field($field_key,$post_id) as mentioned above.

    I have found there are some fields that just aren’t able to get_field() when the calculation is made the first time, and that is what is causing the issue. Once the save is completed the then empty fields are defined, so saving again allows the calculation to process correctly.

    I assumed that since the calculations (code block 2) were happening after the fields are defined (code block 1), then the calculations should be able to pull that data. Is this a bug? If not, then what’s the purpose of having acf/save_post priorities if fields aren’t updated in the order your would expect?

    Can you think of any methods where I can make this data available? If there are not any clean methods, is there anything “hacky” you could think of, like mimicking/forcing a post to save twice programmatically on it’s initial creation (the first save)?

  • I just ran a test and found the function is working, but not all of my fields are available when the second set of code it executed, as I feared. Even setting the priority to 999 does not help, even though it is for sure the last thing executed. Shouldn’t the fields that were updated in part one be available for the code in part two to use?

  • The bulk of the second part was not included because it is very verbose, using basic math functions. Essentially the formulas use data that was copied into the post via the first block of code AND also data that was generated by the user and saved when the post was created. I just put those variables there as an example, but not referencing anything specific. All my data is stored across 100+ ACF fields in the post itself.

  • I’m currently having this issue. I’m using the front-end form and all the checkboxes are:

    <label>
    <input></input>
    “Label Text”
    </label>

    This is making it impossible for me to style since I want to style the label based on input:checked. I wish there was a way to make the output like Saturn suggested, or at the very least wrap the “label text” in a span.

    Has anyone had any luck with this?

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