Created
January 3, 2018 04:49
-
-
Save albionselimaj/b20cbd8ddb3600937468e1cc4b5f42e7 to your computer and use it in GitHub Desktop.
Listing description character limit
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
// Limit listing description character length | |
add_filter('submit_job_form_validate_fields', function( $isValid, $fields, $values ) { | |
$description_character_limit = 280; | |
foreach ( $fields['job'] as $key => $field ) { | |
if ($field['slug'] == 'job_description' && isset($values['job']['job_description']) && strlen($values['job']['job_description']) > $description_character_limit) { | |
return new \WP_Error( 'validation-error', sprintf( __( '%s can\'t be longer than %s characters.', 'my-listing' ), $field['label'], $description_character_limit ) ); | |
} | |
} | |
return $isValid; | |
}, 100, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment