I want the list of users with their email IDs, filtered by some x-profile data.
For example, I want to send an email to users who have checked a checkbox on their profile.
How can I get the info of users filtered by the x-profile data?
I want the list of users with their email IDs, filtered by some x-profile data.
For example, I want to send an email to users who have checked a checkbox on their profile.
How can I get the info of users filtered by the x-profile data?
You must be logged in to post a comment.
You will want to use the
$wpdb
class to execute a query for users with a certain x-profile field value.I’m no MySQL expert, so someone else likely has a better way to write this query (if you do, please share it and I’ll update my code), but here’s one approach to it.
This approach assumes you know the ID of the the BuddyPress profile field you are wanting to run the report on, if you don’t, you can alter the query to check the
[prefix]_bp_xprofile_fields
table for a specific field and use it’s ID for the rest of the query.This approach also assumes you are looking for the email address associated with the users’ WordPress accounts and not some other email field you’ve defined in BuddyPress, if you are looking for one in BuddyPress, you’ll need to perform a somewhat more complicated query because the
[prefix]_bp_xprofile_data
table will have the value you want to check against and the value you want to return under thevalue
field in the table.Now, I’m not certain how you’ll be using this data or where you’ll be implementing it, so I left it in the raw object format that the
$wpdb
class returns.You’d probably want to put this into a plug-in and format the returned value into a CSV or something if you plan to feed it into an email campaign system (you’d also probably want to check the usermeta table for the first and last name fields because most of the email systems I’ve worked with require those, too).
But, this should get you going in the right direction.
According to the buddypress xprofile loop you can query all the user profile data with
And then in the loop you can search for a specific profile data And do What you want, something like:
Maybe this can help!
when i create a group on buddypress,by the group name(kanpur) automatically select the group name members from xprofile data.
ie it select kanpur members from xprofile data automatically after creating the group.