First of all thanks a lot for creating this module. It works amazingly and solves all the problem without writing a single line of code.

Now the problem is, I'm a theme developer and being a theme developer, I'm unable to get the additional FB fields (date of birth, gender, native place. etc.) via views.

What is the best way to get this thing work? I tried creating a custom module but it's going over my head, can't we have it simply by some clicks? If not, can you please guide me through custom module development? I will learn and will try to implement it.

I know I can google it and can start but I need to get this thing done and get started on it, your little help can help me a lot.

Thanks a lot for the great help.

Cheers

Comments

themes mania created an issue. See original summary.

masipila’s picture

Priority: Critical » Normal
Status: Active » Fixed
Issue tags: -views

Hi,

You need to first add the fields that you want to the Drupal user object normally. For example the gender.

Then, you need to create a small module that reacts to the user creation event dispatched by Simple Fb Connect when the user is created. In this module, you need to make an API call to Facebook and read the field (e.g. gender) from Facebook and save the value to the Drupal user field thst you had created.

There is already a sample moduke in the module handbook, see https://www.drupal.org/docs/8/modules/simple-fb-connect/eventsubscriber-...

Cheers,
Markus

themes mania’s picture

Priority: Normal » Critical
Status: Fixed » Needs review

Ok, I have created the module as documented and enabled it successfully.

Now as you said, I created two fields for the profile at admin/config/people/accounts/fields as: -

-----------------------------------
LABEL	           MACHINE NAME
-----------------------------------
First Name         field_first_name
Last Name          field_last_name

I created a module with name "fbprofile" And in fbprofile/src/EventSubscriber/FBProfileSubscriber.php, at line number 114, I added the following code: -

        $graph_node = $this->facebook->get('/me?fields=name,first_name,last_name,gender', $access_token)->getGraphNode();
        $name = $graph_node->getField('name');
        $first_name = $graph_node->getField('first_name');
        $last_name = $graph_node->getField('last_name');
        $gender = $graph_node->getField('gender');
        drupal_set_message("You probably knew this: user's name on Facebook is " . $first_name . $last_name . $name . $gender);

Here I added first name, last name and gender as I found it on https://developers.facebook.com/docs/graph-api/reference/user.

Good thing is, I'm able to print values for the first name, last name, and gender on successful registration in the Drupal set message but how do I save the value to the Drupal user field that I have created.

I feel I'm pretty close, you have been a great help so far, your little help can make this thing a lot easier.

Cheers

themes mania’s picture


I got it, I just needed to do: - 

        $user->set("field_last_name", $last_name);
        $user->set("field_first_name", $first_name);
        $user->set("field_gender", $gender);

Thanks a bunch for this Awesome Module!!

masipila’s picture

Priority: Critical » Normal
Status: Needs review » Fixed

Your welcome and I'm glad that you got it working with the help of the documentation!

I noticed that you changed this support request back to critical after I had changed it to normal. I feel a bit triggered. Please take the following as constructive feedback.

Many (if not most) contrib modules are maintained on the maintainer's free time. This module is one of them. I understand that this support request is important for you but please understand that from module maintainer's point of view only a bug that prevents the whole module from working on all / most sites could be considered critical. By repeatedly flagging your support requests critical, especially after you got a response in a matter of hours, can be easily considered disrespectful towards the volunteer work that I'm doing as a module maintainer.

Having said all this, I'm really glad that you find this module useful and that the example in the module handbook was helpful!

Cheers,
Markus

themes mania’s picture

I'm new to this, will surely take care. Thanks a lot for the quick response.

Cheers

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.