/*Reverse sticky header*/
  1. Home
  2. Knowledge Base
  3. Customizations
  4. PHP Functions
  5. Apply The location autocomplete plugin to a location field in another plugin

Apply The location autocomplete plugin to a location field in another plugin

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/

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Support

To speak to our Agency consultant, fill in the form found at our Contact Page.

"*" indicates required fields

Get Started

Enter your name and email address to get started with your project...

Name*