Find Users Who Have Authenticated with Facebook

I am using Ultimate Facebook on a BuddyPress site. I would like for users to be able to see a list of their Facebook friends who are also registered on the site, so that they can befriend them through the site.

I am able to query the user's Facebook friends and find those who have authenticated the app, but how can I match those up with the existing WP users and return the results? Does the plugin store the user's FB ID when they authenticate? If so I could pretty easily query them that way. Or perhaps I am thinking about this all wrong. Any suggestions? Thanks!

  • Vaughan

    Hi @pollenbrands,

    I've just been looking through the DB & I don't see anywhere where the FB ID is stored in relationship to how they signed up, Some plugins do store it such as Events when you RSVP using FB. But with regards to registration, I can't see anything.

    It only works via the email from what I can tell. It'll register with whichever email address you use to login to facebook with. So You could just compare the email address stored in the wp_users table possibly. I'm not sure of any other way you could do it.

    I'll ask the developer to see if he can think of a different way for you though.

    Hope this helps

  • pollenbrands

    I am able to retrieve a user's FB ID like this:

    	$fb_api_info = get_user_meta( 1, 'wdfb_api_accounts', true );
    	$keys = array_keys($fb_api_info['auth_tokens']);
    	$fb_id = $keys[0];

    I have a JSON object from FB that looks roughly like this:
    {"name":"First Last","id":"407349", "installed": "true"},{"name":"First Last","id":"407620", "installed": "true"}

    Now I need to figure out how to loop through those IDs, query wordpress for the user that has that FB ID, and return each. And of course I need to do this much more efficiently than looping through ALL wp users and trying to find a match. I could really use some help with this - thanks!

  • Hoang Ngo

    Hi @pollenbrands,

    I hope you are doing well today.

    Has checking the code, and it seem that the "wdfb_api_accounts" is store when admin authorize with facebook, not when user register with facebook.

    The key we use to sync facebook users with our local user is the "wdfb_fb_uid", as i checked in the code.

    The function using to create wp user when facebook return is json_perhaps_create_wp_user() line 886(may be diffirent fron your end, but only need to search that function name) in the file wpmu-dev-facebook\lib\class_wdfb_admin_pages.php

    You can debug deeper, but i think as you need is the facebook id link to wordpress user, so i think the "wdfb_fb_uid" is work for you.

    If you have any issues please don't hesitate to let us know so we can assist

    Best Regards

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.