If you are using the Location Autocomplete for BuddyPress and want to apply its feature to a particular field or another plugin, you may use the following function:
function setup_location_autocomplete( $field_name ) { include_once( trailingslashit( LOCATION_AUTOCOMPLETE_PATH ) . 'includes/main-class.php' ); include_once( trailingslashit( LOCATION_AUTOCOMPLETE_PATH ) . 'includes/functions.php' ); $location_autocomplete_instance = BuddyBoss_BPLA_Plugin::instance(); wp_enqueue_script( 'bp-location-autocomplete-main-js', bp_bpla()->assets_url . '/js/bp-location-autocomplete.min.js', array( 'jquery' ), '1.0.0', true ); $data = array( 'address' => $field_name ); wp_localize_script( 'bp-location-autocomplete-main-js', 'BPLA_data', $data ); $location_api_key = bp_bpla()->option( 'location-api-key' ); wp_enqueue_script( 'bpla-googlemap', 'https://maps.googleapis.com/maps/api/js?key=' . esc_attr( $location_api_key ) . '&libraries=places&callback=bp_location_profile.initMap', array( 'jquery' ), '', true ); }
(Please be informed that the code above is just a template and needs to be modified specifically to your requirements.)
Note: Any modifications are considered as custom work already. Know more about our Support Policy here: https://www.buddyboss.com/support-policy/
Did you find it helpful? Yes No
Send feedbackSorry we couldn't be helpful. Help us improve this article with your feedback.