Codex tools: Log in
Contents |
Applies filters that can be hooked to perform specific sanitization procedures for the particular metadata type and key. Does not sanitize anything on it's own. Custom filters must be hooked in to do the work. The filter hook tag has the form "sanitize_{$meta_type}_meta_{$meta_key}".
<?php $clean_value = sanitize_meta( $meta_key, $meta_value, $meta_type ); ?>
(mixed) Sanitized value as processed by any hooked filter functions.
$clean_value = sanitize_meta( 'birth-year', $user_input, 'user' );
add_filter('sanitize_user_meta_birth-year', 'ck_birth-year');
function ck_birth-year( $year ) {
$now = date("Y");
$then = $now - 115; //no users older than 115
if ( $then > $year || $year > $now ) {
wp_die("Invalid entry, go back and try again.");
}
return $year;
}
This function is called by add_meta_data() and update_metadata() WordPress functions.
Since: 3.1.3
sanitize_meta() is located in wp-includes/meta.php.
sanitize_email(), sanitize_file_name(), sanitize_html_class(), sanitize_key(), sanitize_mime_type(), sanitize_option(), sanitize_sql_orderby(), sanitize_text_field(), sanitize_title(), sanitize_title_for_query(), sanitize_title_with_dashes(), sanitize_user()