$postids=$wpdb->get_results(
"SELECT
t1.ID
FROM
$wpdb->posts t1
inner join $wpdb->term_relationships t2 on t2.object_id = t1.ID
inner join $wpdb->term_taxonomy t3
on t3.term_taxonomy_id = t2.term_taxonomy_id and t3.taxonomy = 'category'
inner join $wpdb->terms t4 on t4.term_id = t3.term_id
WHERE t1.post_type='post'
and t4.`name` = 'Россия'
ORDER BY t1.ID ASC");
add_action('wp_ajax_wpcf7_rescanned_form', 'wpcf7_rescanned_form');
add_action('wp_ajax_nopriv_wpcf7_rescanned_form', 'wpcf7_rescanned_form');
function wpcf7_rescanned_form() {
update_option( 'my_option', 'my_value' );
}
add_filter( 'wpcf7_before_send_mail', 'fl_wpcf7_before_send_mail_function' );
function fl_wpcf7_before_send_mail_function( $contact_form ) {
$my_value = get_option( 'my_option' );
}