-
-
Save tnchuntic/77de11d210271b5e543c7ade2314ceba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* partially complete conditional logic functions, submitted to Gravity Forms for help, as once the new select element is switched to, it cannot be switched away from */ | |
function set_conditional( $form ) { | |
?> | |
<script type="text/javascript"> | |
gform.addFilter( 'gform_conditional_logic_fields', 'set_conditional_field' ); | |
function set_conditional_field( options, form, selectedFieldId ){ | |
options.push({ | |
label: 'User Role', | |
value: 'user-role' | |
}); | |
return options; | |
} | |
</script> | |
<?php | |
//return the form object from the php hook | |
return $form; | |
} | |
add_action( 'gform_admin_pre_render', __NAMESPACE__ . '\\set_conditional' ); | |
function set_rule_values( $form ){ | |
?> | |
<script type="text/javascript"> | |
gform.addFilter( 'gform_conditional_logic_values_input', 'set_rule_info' ); | |
function set_rule_info( str, objectType, ruleIndex, selectedFieldId, selectedValue ){ | |
if ( selectedFieldId == 'user-role' ) { | |
str = '<select><option value="company_free">Company Free</option><option value="tech_supporter">Tech Supporter</option><option value="tech_company">Tech Company</option><option value="job_seeker">Job Seeker</option><option selected="selected" value="subscriber">Subscriber</option><option value="contributor">Contributor</option><option value="author">Author</option><option value="editor">Editor</option><option value="administrator">Administrator</option></select>'; | |
// str = str.replace('Enter a value', 'Enter the user role value'); | |
return str; | |
} else { | |
return str; | |
} | |
} | |
</script> | |
<?php | |
//return the form object from the php hook | |
return $form; | |
} | |
add_action( 'gform_admin_pre_render', __NAMESPACE__ . '\\set_rule_values' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment