Support » How-To and Troubleshooting » Data validation for custom fields?

Data validation for custom fields?

  • I’ve checked out the data validation page on the codex http://codex.wordpress.org/Data_Validation and the wp_kses page too http://codex.wordpress.org/Function_Reference/wp_kses

    I’m not quite sure how to validate text boxes and text areas for custom fields.

    I can’t find anything authoritative that I can comprehend on the internet.

    Can anyone tell me how to validate using wp_kses? Apparently ‘You have to remove any slashes from PHP’s magic quotes before you call this function’ (wp_kses codex page).

    The outline of the code that I’m using for my customised custom fields is:

    $meta_box = array
    			'title' => 'blah',
    			'something => 'whatever',
    function show_box( )
    	foreach ( $meta_box['fields'] as $field ) {	
    	case 'text':
    	echo '<label class="custom-fields  ....
    	echo '<input class="custom-fields ......
    add_action( 'save_post', 'save_data' );
    function save_data( $post_id ) {
    	if ( !wp_verify_nonce( $_POST['developer_theme_meta_box_nonce'] ...
    	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) ...
    	if ( 'page' == $_POST['post_type'] ) ....
    function custom_fields( ) {
    	foreach ( $meta_box['page'] as $page ) {
    	add_meta_box( $meta_box['id'], $meta_box['title'], 'show_box',.....
    if ( current_user_can( 'administrator' ) ) :
    add_action( 'admin_menu', 'custom_fields' );  ....

  • The topic ‘Data validation for custom fields?’ is closed to new replies.
Skip to toolbar