Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Front End User Profile Field Form Causes ReferenceError
-
I am using ACF to allow users to modify their user profile from the front end. When I add this code:
$options = array(
'post_id' => 'user_'.$userID,
'field_groups' => array($field_group['ID']),
'submit_value' => 'Save All Changes',
'updated_message' => false
);
acf_form( $options );
it works great except that I get a js "Uncaught ReferenceError: user_[$userID] is not defined". It seems to me that this is happening when ACF tries to set the post ID equal to the given post ID expecting a number but gets a string.
Thanks for all your great work! -
Hi,
From what I saw (I encountered a similar bug), it seems it comes from the fact that post_id expects an integer and is, therefore, not wrap within quotes.
See the JS generated by the acf_form() function below.<script type="text/javascript">acf.post_id = test; acf.nonce = "b2d991a840";</script>
As you see, test is here not wrapped within quotes so it's considered as a variable (which doesn't exist). That's what triggers the error.
Don't know if it will help you, but I thought I'd share this.