Home Processing form data without nonce verification Error on my Function - Wordpress
Reply: 0

Processing form data without nonce verification Error on my Function - Wordpress

user971
1#
user971 Published in August 16, 2018, 6:17 am

Here is my function:

public function save_meta( $term_id = 0, $taxonomy = '' ) {
    $meta = ! empty( $_POST['banner'] ) ? $_POST['banner'] : '';

    if ( empty( $meta ) ) {
        delete_term_meta( $term_id, 'banner' );
    } else {
        update_term_meta( $term_id, 'banner', $meta );
    }
}

And When Travis review the code it tells me that Processing form data without nonce verification. | | (WordPress.CSRF.NonceVerification.NoNonceVerification)

I tried the following but is not working:

public function save_meta( $term_id = 0, $taxonomy = '' ) {
    $meta = ! empty( $_POST['banner'] ) && wp_verify_nonce( sanitize_key( $_POST['banner'] ) ? $_POST['banner'] : '';

    if ( empty( $meta ) ) {
        delete_term_meta( $term_id, 'banner' );
    } else {
        update_term_meta( $term_id, 'banner', $meta );
    }
}

What is wrong with my code?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.345043 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO