Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

CPT & Gravity Forms link WordPress


I'm using Wordpress PODS to create custom post types that link to Gravity Forms for event registration. When a user creates a new "Clinic", for example, it is added to the Gravity Form for Clinic Registration. However, the form is not changing in the back end. Because of this, users are still directed to PayPal to complete payment, but see an error since the shopping cart is empty.

How do I make it so the new CPT's will actually add the item to the gravity form instead of just in the front end? Code from functions.php below:

add_filter('gform_pre_render_1', 'populate_clinics_again');
function populate_clinics_again( $form ){
foreach( $form['fields'] as &$field ) {
if ( $field["id"] == 13 ){
$query = new WP_Query( array( 'post_type' => 'clinics') );
global $post;
$field['choices'] = array();
while( $query->have_posts()) : $query->the_post();
$price = get_post_meta($post->ID, 'cost_of_clinic', true);
$name = get_post_meta($post->ID, 'name_of_clinic', true);
$field['choices'][] = array( 'text' => $name,'price' => $price );
return $form;

Answers (2)


Kyle answers:

Happy to help :)


Arnav Joy answers:

can you explain your question bit more, sorry it is not clear to me,

Patrick MacAdams comments:

Here is the desired process:
1. A user creates a new custom post type, in this case, "Clinic". That CPT has a title and cost.
2. That "Clinic" creates both a post, and is added as a product to a Gravity Form.
3. The above code accomplishes that, but the change to the form is only on the front end. The product is not actually added to the form itself in the back end. So it appears that it has been added to the front end, but doesn't actually add the product.

An test example here:

You'll see a product called "KD5 Clinic". It populates the 'total', but when proceeding to paypal, the cart is empty, because the product isn't added to the actual form. Screenshot of the gravity form dashboard attached. This is the same form as in the example.