I am trying to debug ‘undefined index’ errors on the WP backend when debug is set to TRUE. The offending lines are:

        if ( !wp_verify_nonce( $_POST['pdwt_meta_noncename'], plugin_basename(__FILE__) )) {
    return $post->ID;
    } 

Which I have then changed to check whether the value has been set by adding

    if ( isset( $_POST['pdwt_meta_noncename']) || ! wp_verify_nonce( $_POST['pdwt_meta_noncename'], plugin_basename(__FILE__) )) {
return $post->ID;
}

The later part makes the error disappear but when I enter information on the custom field it does not save.

This is how the custom field has been set

echo '<input type="hidden" name="pdwt_meta_noncename" id="pdwt_meta_noncename" value="' .
    wp_create_nonce( plugin_basename(__FILE__) ) . '" />'; 

Any thoughts on what could be wrong/
Thank you.

Read more here: Undefined index error when saving content on metabox


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , ,

Wordpress related questions and answers: