Created
November 12, 2017 12:14
-
-
Save rahularyan/5fbe1977776c32637e9a1dd325147236 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
/** | |
* This hook will make question description field optional. | |
* | |
* @param array $form Form arguments. | |
* @return array | |
*/ | |
function my_ap_make_question_description_optional( $form ) { | |
$validate = $form['fields']['post_content']['validate']; | |
//remove required from validation. | |
if ( is_array( $validate ) ) { | |
if ( ( $key = array_search( 'required', $validate ) ) !== false ) { | |
unset( $validate[ $key ] ); | |
} | |
} else { | |
$validate = str_replace( 'required', '', $validate ); | |
} | |
// Update existing value. | |
$form['fields']['post_content']['validate'] = $validate; | |
return $form; | |
} | |
add_filter( 'ap_question_form_fields', 'my_ap_make_question_description_optional' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment