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.

Use existing login system

  1. We're using gravity forms on a university website. My idea is a little complex, so hopefully it'll make sense.

    On our old non-Wordpress website, we'd make forms using PHP and include a file at the top called auth.php. When we include that file, it requires people to login with their university ID before they could see the page. Once logged in, it would show the page. We'd also be able to grab the ID and put it in a read-only field so that people could only submit once.

    Is this scenario possible, and if so, does anyone have any ideas on how to make it happen: I'd like to make it so that if anyone creates a field called "AuthID", it would automatically make the form software include the auth.php file so that people would have to log in. We'd also set it so that the AuthID field was read only and pull in their ID. This would allow us to have students make forms and only need to include that field, and not have to do any other coding to make it grab the ID. If the form doesn't include that field, then it wouldn't require anyone to sign in.

    Is something like this possible?

    Posted 9 years ago on Saturday October 6, 2012 | Permalink
  2. So, I've got it pretty much working by following some somewhat related info and having to hack our login system a little to make it work. The only thing I'm now trying to figure out is if there's a way to automatically make the "Allow field to be populated dynamically" checked and filled in. I'm using POST data, and it's working fine pulling it in, but if someone forgets to check that box and put in the parameter name, it'll be useless.

    Posted 9 years ago on Sunday October 7, 2012 | Permalink
  3. is if there's a way to automatically make the "Allow field to be populated dynamically" checked and filled in.

    What do you mean here? Are you showing a field and requiring users to check the box in every case for some reason? What does this field hold?

    Posting this link here for reference: (closed as a duplicate)

    Posted 9 years ago on Monday October 8, 2012 | Permalink
  4. Through some crazy coding, I was able to hack it together. If the field exists, then it makes the form require our authentication system by including a php file. That field would then pull in the username from our authentication system. It's that reason that it would have to be checked every time, otherwise it wouldn't be pulling in the username from our system. This is the code I eventually used that made it so it didn't matter if it was checked or not by changing around from other coding I've seen:

    // Adds the input area to the external side
    add_action( "gform_field_input" , "wps_netID_field_input", 10, 5 );
    function wps_netID_field_input ( $input, $field, $value, $lead_id, $form_id ){
        if ( $field["type"] == "netID" ) {
    		$max_chars = "";
    		if(!IS_ADMIN && !empty($field["maxLength"]) && is_numeric($field["maxLength"]))
    			$max_chars = self::get_counter_script($form_id, $field_id, $field["maxLength"]);
    		$input_name = $form_id .'_' . $field["id"];
    		$inputnamenum = $field["id"];
    		$tabindex = GFCommon::get_tabindex();
    		$css = isset( $field['cssClass'] ) ? $field['cssClass'] : '';
    		return sprintf("<div class='ginput_container'><input readonly name='input_$inputnamenum' id='input_$input_name' type='text' value='$auth_object->netid' class='small' {$tabindex} {$logic_event} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
        return $input;
    Posted 9 years ago on Monday October 8, 2012 | Permalink