Back to Developer Guides

This guide applies to:

  • Basic Edition
  • Plus Edition
  • Pro Edition
  • Business Edition

Description

WordPress Filter that enables you to control which fields will be copied over from a Gravity Forms entry to a Simply Schedule Appointments booking entry.

This is helpful for preventing customer data from being stored in SSA’s database or seeing it in the SSA dashboard interface. And this also prevents the information from being used in appointment notifications and Google Calendar sync.

Learn more about how our Gravity Forms integration works when managing appointment details.

Placement

This code should be placed in the file of your custom plugin.

Source Code

This filter is located in the SSA_Gravityforms::book_appointment_after_form_submission() function in class-gravityforms.php.


Usage

add_filter('ssa/forms/gravity/should_copy_field_to_ssa', 'ssa_gforms_should_copy_field_to_ssa', 10, 5);

Parameters

  • $should_copy boolean
    Identify whether to copy a field over to SSA appointment or not. The default is true.
  • $form_id int
    The ID of the Gravity Form.
  • $gf_ssa_field_id int
    The ID of the current SSA field in the Gravity Form.
  • $gf_field_to_copy_type string
    The type of the current field in the Gravity Form. For example, “number” for a number field.
  • $gf_field_to_copy_id int
    The ID of the current field in the Gravity Form.

Example – Prevent specific gravity forms fields and field types from copying to SSA customer information

add_filter('ssa/forms/gravity/should_copy_field_to_ssa', 'ssa_gforms_should_copy_field_to_ssa', 10, 5);

/**
 * 
 * For a form with 2 SSA fields, and 10 non-SSA fields
 * This filter will run 10 times for each SSA field
 * 
 * 
 * 
 * @param boolean $should_copy
 * @param integer $form_id
 * @param integer $gf_ssa_field_id ID of an SSA field in the form
 * @param string $gf_field_to_copy_type Type of the field you're deciding to copy over to the appointment or not
 * @param integer $gf_field_to_copy_id ID of the field you're deciding to copy over to the appointment or not
 * 
 * @return boolean $should_copy
 */

function ssa_gforms_should_copy_field_to_ssa( $should_copy, $form_id, $gf_ssa_field_id, $gf_field_to_copy_type, $gf_field_to_copy_id ) {

    // example to exclude all fields on appointments corresponding to SSA field of ID 1
    // use this if you want to copy the fields to one appointment but not the others in a form that includes multiple SSA appointment fields
    if( 1 == $gf_ssa_field_id ){
        $should_copy = false;
    }

    // example to exclude all fields on form of ID 1
    if( 1 == $form_id ){
        $should_copy = false;
    }
    
    // example to exclude any field of type 'number'
    if( 'number' == $gf_field_to_copy_type ){
        $should_copy = false;
    }
    
    // example to exclude any field with ID '8'
    if( 8 == $gf_field_to_copy_id ){
        $should_copy = false;
    }
    
    // example to exclude all fields of type checkbox unless the field ID is '6'
    if( 'checkbox' === $gf_field_to_copy_type && 6 != $gf_field_to_copy_id ){
        $should_copy = false;
    }
    
    return $should_copy;
}

Still stuck?

File a support ticket with our five-star support team to get more help.

File a ticket

  • Please provide any information that will be helpful in helping you get your issue fixed. What have you tried already? What results did you expect? What did you get instead?
  • This field is for validation purposes and should be left unchanged.

Related Guides