I’m trying to create security question field for my login page

There is no login_post action that I know of – use the authenticate filter instead, inside wp_authenticate(), called by wp_signon():

function wpse_185339_check_user_answer( $user ) {
    if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) {
        if ( empty( $_POST[ 'user_proof' ] ) ) {
            $user = new WP_Error( 'proofempty', '<strong>ERROR</strong>: You did not answer the proof-of-humanship question.' );
        } elseif ( strtolower( $_POST[ 'user_proof' ] ) !== 'white' ) {
            $user = new WP_Error( 'prooffail', '<strong>ERROR</strong>: You did not answer the proof-of-humanship question correctly.' );
        }
    }

    return $user;
}

add_filter( 'authenticate', 'wpse_185339_check_user_answer', 100 );

Leave a Comment