I was considering using CB for handling custom user fields, but actually I do not need it.
So (call me crazy) I am considering creating my own JFB Connect Plugins to fill my tables with user data from facebook.
Please just check if I am getting this right:
function jfbcProfilesOnRegister($jUserId, $fbUserId)
function jfbcProfilesOnAuthenticate($jUserId, $fbUserId)
We're working on more developer-friendly documentation, but hopefully we can help you through everything you need to know here for now!
Your general idea is spot-on. Just create the JFBCProfile plugin and don't touch anything else. We've tried to make it easy to do what you're saying so that you don't have to modify any of our code, which will let you upgrade JFBConnect easily and not have to re-implement your code.
The 3 functions are the main ones to look at. The other one you'll want is "addFieldToDb". Here's a quick overview of the functions, but please test and ask questions as I may be wrong on something:
jfbcProfilesOnAuthenticate($jUserId, $fbUserId) - Used for checking if the user is allowed to login. You'll likely just return true here (or don't even implement it)
jfbcProfilesOnRegister($jUserId, $fbUserId) - Used to do stuff on the first time a user registers on your site. Most of our plugins just call the same logic as OnLogin (below)
jfbcProfilesOnLogin() - Used to do something when the user logs in. This is usually where the users profile is imported from FB into a database. Generally, this should just call parent::importFBProfile(); which will call the function below repeatedly to make your life easier.
addFieldToDb($fieldId, $value) - This should take a fieldId (set in your usermapping) and hand you the value from Facebook to use in that field. You can figure out what to do with it from there (write to file, write to your table, etc).
The mapping of fields from your table to Facebook is configured in the /tmpl/configuration.php file of your plugin. Here, just put select lists for each of your fields, give them an integer id (used as the $fieldId in addFieldToDb) and show the Facebook fields to map to it (see other profile configuration files for reference). Once this is saved, then when the user is logged in, we'll call addFieldToDb repeatedly with the id and actual value from the user's profile for you, so you just have to 'do' something with those tidbits of info. Additionally, by using the usermap functionality, JFBConnect will automatically ask for the permissions you need to get that information.
Finally, the only last bit of knowledge to impart is that you need to setup the constructor similar to the other profile plugins. Mainly, the settings value which are any settings for the plugin you'll want to save in the database to use later as well as a component directory to check if you're profile plugin is installed.. since you may not have one, you probably can just put JPATH_ADMINISTRATOR there so that JFBConnect always thinks your plugin should run.
Hope this all helps, and again, ask questions. This post will likely be the start of a document we'll throw up on the main JFBConnect overview page, so thanks for forcing us to finally start jotting this stuff down!
Just a note to say I followed your instructions and my little plugin works just fine.
And now, I am also putting
in many of my files... and using it intensively
Thank you guys, for saving me all the headaches of dealing with Facebook programming... you are the true "Operation Developer Love".
That's fantastic to hear, and we're glad to hear you're really getting along with JFBConnect. Certainly if you need anything else from us, just let us know.
Finally, I'm not sure if you left a review on the JED, but there was one recently from someone named Sylvester who had done some programming of a profile plugin... if that was you, thank you very much for your time. It's very appreciated.
Best of luck to you,
Yes, sir... that whas me on JED.
"SylvesterFaro" is my funny username (check the avatar) - JED shows "username" and not "name".
I take the oportunity to suggest you do show "name" and not "username" in this forum... its harder to recognize " fb_100000157901698" as the coolest guy in the forum.
I meant to mention your avatar after I said Sylvester.. I made the connection
We've considered changing what we show as the name.. but also, in the upcoming 4.0 release, we've already implemented a way (for an admin) to select the auto-generated username by either setting it to:
fb_123456 (what we've done for a while)
First.Last22 (FirstName followed by . followed by LastName followed by small unique ID)
FirLas22 (first 3 chars of first name followed by first 3 of last name followed by unique ID)
Once we get that up, we'll probably move to that system so you (don't know your last name, lets assume it's smith) would have had an auto name of "alesmi22" maybe
Thanks for the suggestions and the review, and best of luck with your site!