PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Custom field with Facebook Like

  1. Hi guys,

    I'm new to Gravity Form but I already love it :-) !

    Here is what I'm trying to achieve.

    I want to build up a form (name, firstname, email, checkbox) that will display a FACEBOOK LIKE button just before the SUBMIT button. This form will be use to subscribe to a contest. If you subscribe and LIKE the fan page of my client, you will have two chance to win something (if you don't like, only one...).

    So I decided to add a custom field. I used gform_add_field_buttons to insert a button on the editor.

    add_filter("gform_add_field_buttons", "add_facebooklike_field");
    function add_facebooklike_field($field_groups){

    foreach($field_groups as &$group){
    if($group["name"] == "advanced_fields"){
    $group["fields"][] = array("class"=>"button", "value" => "Facebook Like it !", "onclick" => "StartAddField('facebook-like');");
    break;
    }
    }
    return $field_groups;
    }

    Then I used gform_field_input to display the good input.

    I use the wonderful Simple Facebook Connect by Otto to do all my facebook stuff.

    The problem is that the button appears in the editor but not on my form preview.

    add_action("gform_field_input", "facebooklike_input", 10, 5);
    function facebooklike_input($input, $field, $value, $lead_id, $form_id){
    echo $field["type"];
    if($field["type"] == "facebook-like"){
    $input = sfc_like_button();
    }
    return $input;
    }

    How can I fix that ?

    Then I would like to add a value on submit to check if the user has LIKE or NOT the page before submitting it… Any advice on how I can do that ?

    How should I create custom field properties… ? Is there a filter for that ?

    Thanks in advance for your time and patience.

    Jk_

    Posted 13 years ago on Thursday November 10, 2011 | Permalink
  2. Ok I just realize that I made a mistake, I replace sfc_like_button(); by a HTML5 Like box.

    It works properly now.

    My two questions here remains unanswered tough :-) :

    Then I would like to add a value on submit to check if the user has LIKE or NOT the page before submitting it… Any advice on how I can do that ?

    How should I create custom field properties… ? Is there a filter for that ?

    Posted 13 years ago on Thursday November 10, 2011 | Permalink