Support

  1. cheshirealan
  2. Support
  3. Monday, December 02 2019, 10:53 AM
I have decided to try and geocode all my users without the need for them to edit their profiles to force it.
I am using the custom approach based on town/city, country and Post Code.

Is their a simple piece of code I could use in a batch file that could execute geocoding if the gmap field is empty.

I already have a batch file running under cron that loops around all the users updating fields from with data from other extensions.
admin Accepted Answer
Admin
Hi,
sorry but we does not have a piece of code to make this already done.

Do you load Joomla environment in your batch file? I ask you this because Easy Profile have own libraries to do this.
  1. more than a month ago
  2. Support
  3. # 1
cheshirealan Accepted Answer
Content Protected
  1. more than a month ago
  2. Support
  3. # 2
admin Accepted Answer
Admin
Hi,
have you tried to assign the value with JSN user object (http://docs.easy-profile.com/index.php/article/jsnuser-object)?

For example:
I assume gmap have alias like "address"
require_once(JPATH_SITE.'/components/com_jsn/helpers/helper.php');
$user=JsnHelper::getUser($user_id);
$user->setValue('address',$town . ' ' . $country . ' ' . $post_code);
$user->save();
  1. more than a month ago
  2. Support
  3. # 3
cheshirealan Accepted Answer
Many thanks.

Here is the code I ended up with that works and may be of use to others:

require_once(JPATH_SITE.'/components/com_jsn/helpers/helper.php');
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id')
->from('#__jsn_users')
->where('location is NULL')
->order('id');
$db->setQuery($query);
$user_ids = $db->loadColumn();
foreach ($user_ids as $user_id)
 {
 $user=JsnHelper::getUser($user_id);
 $user->setValue('name_of_gmap_field',$user->customfield_1 . ' ' . $user->customfield_2 . ' ' $user_>customfield_3);
 $user->save();
 }
  1. more than a month ago
  2. Support
  3. # 4
cheshirealan Accepted Answer
Sorry, i forgot to change one of the field names:

require_once(JPATH_SITE.'/components/com_jsn/helpers/helper.php');
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id')
->from('#__jsn_users')
->where('name_of_gmap_field is NULL')
->order('id');
$db->setQuery($query);
$user_ids = $db->loadColumn();
foreach ($user_ids as $user_id)
{
$user=JsnHelper::getUser($user_id);
$user->setValue('name_of_gmap_field',$user->customfield_1 . ' ' . $user->customfield_2 . ' ' $user_>customfield_3);
$user->save();
}
  1. more than a month ago
  2. Support
  3. # 5
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Request Support

Support is currently Offline

Support Availability

Working days: Monday to Friday. The support staff is not available on weekends; in the most of cases tickets will not be answered during that time.

Reply time: Depending on the complexity of your support issue it's usually between a few minutes and 24 hours for paid members and about one week for free members. When we expect longer delays we will notify you.

Guidelines

Before you post: read the documentation and search the forums for an answer to your question.

When you post: include Site Details if you request a support (you can use the form below the reply in Site Details tab).

Auto Solved Question: If after a week the author of the post does not reply to a request by moderator, the question will be marked as resolved.

Language: only English

Search Users

Easy Profile® is not affiliated with or endorsed by Open Source Matters or the Joomla Project. Joomla is Free Software released under the GNU/GPL License.