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.

How to check parameter before form loads

  1. craigedmonds
    Member

    I want to pass a parameter to the GF EG: &serviceid=999 and check against another database for the serviceid.

    If the serviceid is valid then we can load the form, if not, then we need to redirect to another page.

    Probbaly I will need to use a hook for this but which one?

    Posted 13 years ago on Thursday September 8, 2011 | Permalink
  2. craigedmonds
    Member

    [SOLVED]

    I have solved my issue by using the code below. I am tweaking the code more but thought I would update just to say I had found a solution, before anyone answers.

    add_filter("gform_pre_render_8", "services_check_serviceid_pre_form");
    
    function services_check_serviceid_pre_form($form){
    
    	//we need to check with the whmcs database for a valid service id as we only want to allow access to the form for clients who have have a valid and paid invoice
    
    	//check if serviceid parameter exists and if not, redirect
    	if(empty($_GET["serviceid"])){
    
    		echo 'Sorry but there was an issue with your request';
    		echo '<br><br>';
    		echo 'Please contact <a href="support@marbellaguide.com">support@marbellaguide.com</a> if you continue to receive this error';
    
    	} else {
    
    		$whmcsservicesid = $_GET["serviceid"];
    // some stuff here to verify the serviceid
    
    	//if everything is okay, display the form
    	echo 'Your Service Reference is: ' .$whmcsservicesid;
    	return $form;
    
    	}
    
    }
    Posted 13 years ago on Thursday September 8, 2011 | Permalink
  3. Thanks again for posting your solution.

    Posted 13 years ago on Thursday September 8, 2011 | Permalink

This topic has been resolved and has been closed to new replies.