Created
April 20, 2019 04:26
-
-
Save yeriepiscesa/c7202b0938732ee696b1e9e34b65558e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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