Skip to content

Instantly share code, notes, and snippets.

@yeriepiscesa
Created April 20, 2019 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yeriepiscesa/c7202b0938732ee696b1e9e34b65558e to your computer and use it in GitHub Desktop.
Save yeriepiscesa/c7202b0938732ee696b1e9e34b65558e to your computer and use it in GitHub Desktop.
<?php
function filter_wpcf7_load_provinces( $scanned_tag, $this_exec ) {
if( $scanned_tag['name'] == 'province') {
global $wpdb;
$provinces = $wpdb->get_results( "select * from {$wpdb->prefix}provinces order by id asc", OBJECT );
foreach( $provinces as $province ) {
$scanned_tag['raw_values'][] = $province->name;
$scanned_tag['values'][] = $province->id;
$scanned_tag['labels'][] = $province->name;
}
}
return $scanned_tag;
};
add_filter( 'wpcf7_form_tag', 'filter_wpcf7_load_provinces', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment