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.

gform_pre_render not effecting form

  1. edlab
    Member

    I am trying to switch required fields to not required based upon a users logged in status. Just trying to get exisiting required to switch and not getting any change. The function and filter do work because the form does display. Note there is no logged in conditional in the function yet.

    add_filter('gform_pre_render_1', 'form_logged');
    
    function form_logged($form){
    
    	print $form['field'];
    
    	foreach($form['fields'] as $field){
    
    		if($field['isRequired']){
    	                $field['isRequired'] = true;
    	                return $form;
    
    		}
    
    	}
    
    }
    Posted 13 years ago on Tuesday April 19, 2011 | Permalink
  2. edlab
    Member

    omit the print $form['fields]; a holdover from working on this.

    Posted 13 years ago on Tuesday April 19, 2011 | Permalink
  3. edlab
    Member

    I found my solution. I am simply using this for each entry that is required. But wrapped in an if statement for the users status.

    $form['fields][0]['isRequired'] = false;
    Posted 13 years ago on Tuesday April 19, 2011 | Permalink