Home › Forums › Front-end Issues › Using Gravity Forms to add Relationship Field
Is it possible to have a form populate a relationship field? I have a form that is passing on an ID that needs to get saved in a relationship field… This is using a GF hidden field. It appears that the relationship meta value is being populated with a straight-up value, but of course relationship fields need to be serialized. What are the other values in the serialized value for? Could I just find a way to add the other details on to my ID?
I was able to figure it out thanks to this:http://wordpress.stackexchange.com/questions/78826/inserting-gravity-form-checkbox-values-into-advanced-custom-fields
One thing I ran into is that if I needed the serialized value for a field, the “get_post_custom_values” function worked. Otherwise, the ACF “get_field” function was what I needed for other types of fields.
add_action("gform_after_submission_2", "acf_post_submission", 10, 2);
function acf_post_submission ($entry, $form)
{
$post_id = $entry["post_id"];
// funding status
$values = get_field("reviewer_funding_status", $post_id);
echo "<br />reviewer_funding_status: " . $values;
update_field("field_519f97aab12f7", $values, $post_id);
// rating - overall
$values = get_field("rating_overall", $post_id);
echo "<br />rating_overall: " . $values;
update_field("field_519f989ab12f8", $values, $post_id);
// rating - clarity of mission
$values = get_field("rating_clarity_of_mission", $post_id);
echo "<br />rating_clarity_of_mission: " . $values;
update_field("field_520be9eac3f72", $values, $post_id);
// rating - communications
$values = get_field("rating_communications", $post_id);
echo "<br />rating_communications: " . $values;
update_field("field_519f98d4b12f9", $values, $post_id);
// rating - evaluation
$values = get_field("rating_evaluation", $post_id);
echo "<br />rating_evaluation: " . $values;
update_field("field_520be9fdc3f73", $values, $post_id);
// funder ID
$values = get_post_custom_values("funder_id", $post_id);
echo "<br />funder_id - serialized: " . $values;
update_field("field_519f996ce16ca", $values, $post_id);
}
I totally forgot about this… may have to reference it myself sometime, ha!
The topic ‘Using Gravity Forms to add Relationship Field’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🤔 Curious about the ACF user experience? So are we! Help guide the evolution of ACF by taking part in our first ever Annual Survey and guarantee you’re represented in the results. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 8, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.