[buddypress-trac] [BuddyPress Trac] #7290: 2.7.0-rc2 breaks GeomyWP + Groups Locator groups list
buddypress-trac
noreply at wordpress.org
Sun Oct 30 03:24:44 UTC 2016
#7290: 2.7.0-rc2 breaks GeomyWP + Groups Locator groups list
-------------------------------+----------------------
Reporter: dreadedhamish | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Groups | Version:
Severity: normal | Resolution: invalid
Keywords: reporter-feedback |
-------------------------------+----------------------
Comment (by ninjew):
@boonebgorges,
I have been trying integrate my Groups Locator extension with BuddyPress
2.7 but with no success so far.
I will explain how my extension work and how I integrated it in the
previous version of BuddyPress, and hopefully you will be able to help me
out integrating it with BP 2.7.
The purpose of my extension is to geotag BP groups and to be able to
search and find groups based on address, distance and more. The extension
creates a custom table in database `gmw_groups_locator` where it holds the
location information of each groups together with the group ID to be able
to map it when doing the search query. So the table has columns like id,
address, city, state, lat, lng and a few more.
The groups proximity search is being done using a custom search form
created using GEO my WP plugin ( the core plugin ). On form submission the
form values pass via GET into the search query. In order to query the
search results based on location and distance, the Groups Locator
extension uses the bp_has_groups() function; by passing some of the form
values via $args into the function but also by modifying the main SQL
query. To modify the SQL query I used both
`bp_groups_get_paged_groups_sql` and `bp_groups_get_total_groups_sql`
filters.
In order to modify the main query to only pull groups within a specific
radius from a specific address, I extended the query by modifying its
clauses.
The SELECT clause i extended with something like:
{{{#!php
<?php
$wpdb->prepare( ", gg.id, gg.lat, gg.lng, gg.address,
gg.formatted_address, gg.map_icon, ROUND( %d * acos( cos( radians( %s ) )
* cos( radians( gg.lat ) ) * cos( radians( gg.lng ) - radians( %s ) ) +
sin( radians( %s ) ) * sin( radians( gg.lat) ) ),1 ) AS distance",
$radius, $lat, $lng, $lat );
}}}
and the `groups_from` clause I extended like:
{{{#!php
<?php
`{$wpdb->prefix}gmw_groups_locator` gg WHERE g.id = gg.id AND ";
}}}
The above added a few important fields to the groups object like address,
coordinates, map icon and the distance from the original address that was
entered in the form.
I also added a custom HAVING clause like:
{{{#!php
<?php
$wpdb->prepare(" HAVING distance <= %d OR distance IS NULL ", $radius );
}}}
Which would filter the groups based on if they are within the range of
radius entered in the form.
Now, with BP 2.7 and the split query, I am unable to figure this out yet.
In BP 2.7 the main query ( which used to query and pull all groups data )
now only pulls the groups ID which makes it impossible for me to add all
the extra group data ( address, lat, lng and so on ) into the groups
object. It seems that now the groups object is being pulled from database
using BP_Groups_Group->populate(); ( This is happening within a foreach
loop of the groups ID returning from the main query ) but I don't see any
filters or a way to modify the populate() function in order to extend the
groups object with the custom data from my extension.
This is where I am stuck and hopefully someone can help out.
FYI, I have been away from the project and development for about 6 months
and I just got back to it recently. So please forgive me if that is
something simple that I am missing :).
Thanks,
Eyal
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7290#comment:22>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list