Script for bulk updating users

Support MB Geolocation Script for bulk updating users

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #46868
    digisavvydigisavvy
    Participant

    This question has been asked here enough I wanted to contribute my solution.

    I have a project where I imported 1000 users into a WP site. I set up custom fields with MB. Some of those fields are address fields using MB Geolocation functionality. I could not figure out how to bulk update the addresses and generate latitude and longitude values. Using Google Maps API. I'm using facetwp with their map facet addon, and you can only get users to appear when there are latitude/longitude values present (also using User CPT addon, so clutch)

    I created a script (with the help of Claude) that is a wp cli command. https://gist.github.com/digisavvy/d35159a93a5d5959d4e348447eb6f2d8

    The script looks for users only with values in the address_student field and processes the record to update the latitude and longitude values.

    You could adapt this to regular posts or CPTs in WordPress.

    #46878
    PeterPeter
    Moderator

    Hello,

    Thank you for sharing the solution. Supporting the customization code is beyond our scope of support. However, other users can refer to your solution to update the field in bulk by using WP CLI.

    #46900
    digisavvydigisavvy
    Participant

    Thanks, Peter!

    I wanted to add that the reason I chose to do this as a WP CLI command is so I could easily see the output of the command running and generate lat/lon values for each user. Obviously this takes a while to run but you only do it once.

    This could be adapted to not use wp cli but I think running it from command line is a really good approach.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.