MyListing User Location Field
The {CODICTS} MyListing User Location Field plugin adds a new “Location” profile field type to MyListing’s User Roles system. This lets you add an interactive location/address field to the user registration form and account details page — complete with address autocomplete, an interactive map picker, geolocation detection, and manual coordinate entry.
The location field also appears on WordPress admin user profile pages, so administrators can view and edit user locations from the backend.
Installation & Activation
Start by downloading the plugin from the Downloads page on your dashboard on the CoDicts website.
After downloading, install and activate the plugin in WordPress by navigating to “Plugins” > “Add New” > “Upload Plugin” and selecting the downloaded zip file. Click “Install Now” and then “Activate”.
On activation, the plugin automatically copies its template file to your child theme. There is no settings page — the Location field is configured through MyListing’s existing User Roles admin interface.
Key Features
| Feature | Description |
|---|---|
| Location Profile Field | Adds a new “Location” field type to MyListing’s User Roles profile field system, alongside the built-in Text, Email, Password, and other field types. |
| Address Autocomplete | Integrated address search with autocomplete powered by your configured Maps provider (Google Maps or Mapbox). |
| Interactive Map Picker | Embedded map where users can click to set their location visually. |
| Geolocation Support | “Get My Location” button that uses the browser’s Geolocation API to auto-detect the user’s position. |
| Manual Coordinates | Option to enter latitude and longitude manually for precise positioning. |
| Lock/Unlock Pin | Toggle to lock the map pin in place, preventing accidental repositioning. |
| Registration & Account Details | Location field can be shown on both the registration form and the account details page. |
| Admin Profile Integration | Location field displayed on WordPress admin user profile pages for viewing and editing. |
How It Works
The plugin registers a new “Location” field type within MyListing’s User Roles system. Once activated, you can add the Location field to any user role’s registration form or account details page — just like you would add a Text or Email field.
When users encounter the Location field, they see an interactive interface with multiple ways to set their location:
| Input Method | How It Works |
|---|---|
| Type an address | Start typing in the address input — an autocomplete dropdown appears with matching addresses. Select a suggestion and the map pin moves to that location. |
| Click on the map | Click anywhere on the interactive map to set the location. The address field updates automatically with the reverse-geocoded address. |
| Get My Location | Click the 📍 icon to detect the user’s current position via the browser’s Geolocation API. |
| Enter coordinates | Toggle the manual coordinate inputs to enter precise latitude and longitude values. |
| Lock the pin | Use the lock toggle to prevent accidental repositioning of the map pin. |
The location data (address, latitude, longitude) is saved to the user’s profile and is also accessible from the WordPress admin user profile pages.
Adding the Location Field to a User Role
1. Navigate to Theme Options → User Roles in the WordPress admin (MyListing’s settings).
2. Select the role you want to edit (Primary or Secondary).
3. In the available field types, you will see “Location” (labeled {C} Location in presets).
4. Add the Location field to the role’s field list.
5. Configure the field properties:
| Property | Description |
|---|---|
| Label | The label displayed above the field (e.g., “Your Location”). |
| Description | Optional help text displayed below the field. |
| Placeholder | Placeholder text for the address input (e.g., “Enter your address…”). |
| Required | Whether the field is mandatory. |
| Show in Register Form | Whether to display the field during registration. |
| Show in Account Details | Whether to display the field on the account details page. |
6. Save the user role configuration.
Using the Location Field on the Frontend
Once the Location field is configured for a user role, it appears on the registration form and/or account details page (depending on your settings).
1. Type an address — start typing in the address input. An autocomplete dropdown appears with matching addresses from your configured Maps provider. Click a suggestion to populate the address, and the map pin moves to that location.
2. Click on the map — click anywhere on the interactive map to set the location. The address field is automatically updated with the reverse-geocoded human-readable address.
3. Use “Get My Location” — click the 📍 icon to detect the user’s current position via the browser’s Geolocation API. The address and map update automatically.
4. Enter coordinates manually — click “Enter coordinates manually” to reveal latitude and longitude input fields for precise entry.
5. Lock the pin — use the lock toggle to prevent the map pin from being accidentally moved.
6. Submit the form. The location data (address, latitude, longitude) is saved to the user’s profile.
Editing User Location in the Admin
1. Navigate to Users → All Users and click on a user, or go to Users → Your Profile.
2. Scroll down to the “Location Information” section.
3. The same interactive location field is displayed with the map, address autocomplete, and coordinate inputs.
4. Edit the location as needed and click Update Profile to save.
Example Setup
1. Activate the plugin with the MyListing theme and a child theme active. The template is automatically copied to the child theme.
2. Go to Theme Options → User Roles.
3. Select your Primary user role.
4. Add the “Location” field to the role’s field list.
5. Set the label to “Your Location,” enable Show in Register Form and Show in Account Details.
6. Save the role configuration.
7. Visit the registration page. The location field appears with an address input, interactive map, and geolocation button.
8. Register a test user and set a location. Then go to Users → All Users, click the user, and scroll to “Location Information” — the same location data is visible and editable from the admin.
Frequently Asked Questions
Does this require a child theme?
Yes. The plugin copies a modified template file to the child theme to register the Location field type within MyListing’s User Roles system. Without a child theme, the template override cannot work.
Is there a settings page?
No. The Location field is configured entirely through MyListing’s existing User Roles admin interface at Theme Options → User Roles.
What Maps provider does the field use?
The plugin uses whichever Maps provider is configured in MyListing’s settings — either Google Maps or Mapbox. A valid API key must be configured for autocomplete, geocoding, and map rendering to work.
Where does the location field appear?
After configuration, the field appears in two places: on the MyListing frontend registration form and/or account details page (depending on your settings), and on the WordPress admin user profile pages.
Can users add multiple locations?
No. The field is limited to a single location per user.
Can I change the default map location?
The default map center (London, UK) is built into the plugin. When a user has no saved location, the map defaults to this position. To change it, the plugin source would need to be modified directly.
What happens to location data when I deactivate the plugin?
The location data stored in the user profile is preserved even when the plugin is deactivated or deleted. However, the template file is removed from the child theme, so the Location field type will no longer be available in MyListing’s User Roles system.
Will this conflict with MyListing updates?
Potentially. The plugin overrides MyListing’s user-roles.php template in the child theme. If MyListing significantly changes this file in a future update, you may need to update the plugin to get a compatible template version. After updating MyListing, verify that the User Roles system still works correctly.
Does the plugin create any database tables?
No. Location data is stored in the standard WordPress user meta table.
Troubleshooting
Location Field Not Appearing in User Roles Settings
| Cause | Solution |
|---|---|
| Template not installed | Deactivate and reactivate the plugin to trigger template installation. Ensure both the MyListing theme and a child theme are active. |
| Plugin not activated | Go to Plugins → Installed Plugins and verify the plugin is active. |
| MyListing or child theme not active | Both the MyListing theme and a child theme must be active. Check Appearance → Themes. |
Map Not Displaying or Autocomplete Not Working
| Cause | Solution |
|---|---|
| Maps provider not configured | The location field relies on MyListing’s built-in Maps integration. Go to MyListing’s settings and ensure Google Maps or Mapbox is configured with a valid API key. |
| Invalid or expired API key | Check your Maps provider API key. Google Maps requires a valid key with the Maps JavaScript API, Places API, and Geocoding API enabled. |
| JavaScript error | Check the browser console (F12 → Console) for errors. The map requires MyListing.Maps.loaded to be true before initializing. A missing or invalid API key is the most common cause. |
“Get My Location” Not Working
| Cause | Solution |
|---|---|
| HTTPS required | The browser Geolocation API requires the site to be served over HTTPS. Ensure your site uses SSL. |
| Browser permission denied | The user must grant location permission when prompted by the browser. Check browser settings if the permission was previously denied. |
Location Field Not Appearing on Registration Form
| Cause | Solution |
|---|---|
| “Show in Register Form” not enabled | Edit the Location field in User Roles settings and make sure Show in Register Form is toggled on. |
| Field not added to the role | The Location field must be added to the specific role’s field list in Theme Options → User Roles. Check that the field is present for the correct role (Primary or Secondary). |
| Wrong user role selected during registration | If the field is only configured for one role (e.g., Secondary), it will only appear when that role is selected on the registration form. |
Location Data Not Saving
| Cause | Solution |
|---|---|
| No location set | Users must set a location using one of the input methods (autocomplete, map click, geolocation, or manual coordinates) before submitting the form. An empty field will not save location data. |
| Form validation error | If the field is set to “Required” and no location is provided, form submission will be blocked. Ensure a location is selected. |
Template Overwrite Warning
The following template file in your child theme is managed by this plugin and will be overwritten on activation:
includes/src/user-roles/user-roles.php
If you have custom modifications to this file, back them up before activating the plugin. Plugin updates will also re-install the latest version of this template.
“MyListing Theme Not Detected” or “Child Theme Not Detected” Error
The MyListing theme and a child theme must both be installed and active. Go to Appearance → Themes to verify.
For further support, visit codicts.com or contact us at support@codicts.com.