Topic-icon Using SCLogin conditionally for specific social networks

Active Subscriptions:

None
Hi,
I am using SCLogin module under a PHP condition however it doesn't show up even when the condition is specified in a PHP Layout file.
- Is this an improper usage?
- Is there an api to check whether a user has logged in using a particular social network right now from the session?
- Also is there a parameter that can be passed to SCLogin to only show particular social network logins, e.g. I need only LinkedIn to show when user has not logged in with LinkedIn.

<section id="section-3">
<h2 class="text-center">Turn your linkedin profile into an impressive resume</h2>
<p>In just one click.</p>
<?php
if ($linkedInUser < 1) // does the user have a linkedInUser login
{
?>
<p style="font-size:1.4em;">To use this feature please sign in with your Linkedin account</p>
{module 113}
<?php
}
else
{
?>
<p><a href="index.php?option=com_rsform&view=rsform&layout=misterlinkedinguy"><img src="images/linked_in_temp.png" /></a></p>
<?php
}
?>
</section>

Best wishes,
Pawan.
The topic has been locked.
Support Specialist
The SCLogin module has a "Providers" option, which you can just put "linkedin" into. That will only show the LinkedIn login button to guests.

Alternatively, you can use the following Easy-Tag, instead of the whole SCLogin module, to just show that button:
{JFBCLogin providers=linkedin}

- Is this an improper usage?

I don't know. Where is the $linkedinUser variable coming from?
- Is there an api to check whether a user has logged in using a particular social network right now from the session?
Not really. You can determine if the current user has mapped their account to LinkedIn. If they have, it doesn't matter if they used that to login or not this time, since there will be an access token stored for that user which can be used on their behalf whether they are currently logged into Linkedin.com or not.

I hope that helps,
Alex
The topic has been locked.
Active Subscriptions:

None
Alex,
after login, $linkedInUser is fnding whether the current user is logged in using the social network, and thus has linkedIn data imported, or not.
$db->setQuery("SELECT count(*) from `#__jfbconnect_user_map` where `j_user_id` = '".$usid."' and `provider` = 'linkedin' ");
$linkedInUser = $db->loadResult();

- For a logged in user, will the SCSocialWidget or JFBCLogin show up or not? Is there a restriction that a user already logged in will not be shown these login widgets?
Even outside the condition I am not able to get the widget to show: maybe this is because the user is logged in.
Regards,
Pawan.
The topic has been locked.
Support Specialist
I think I understand now. Let me re-state what you're looking for to make sure:
* User logs into your site
* You want to check if they have logged in with LinkedIn
* If not, you want to show the "Connect with LinkedIn" button so that they can associate the current account they are logged in with to their LinkedIn account as well.

If that's correct, the following code should work for you:
<?php 
if ($linkedInUser < 1) // does the user have a linkedInUser login 
{ 
     ?> 
     <p style="font-size:1.4em;">To use this feature please sign in with your Linkedin account</p>
     {JFBCLogin show_reconnect=true providers=linkedin}
<?php
 } else {
 ....
That JFBCLogin tag will only show the LinkedIn Login button and it will also show when the user is already logged in, but hasn't connected to their LinkedIn account.

I hope that helps, but if you have any other questions, just let me know.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
Alex,
It works, and reconnects with the specific LinkedIn button, and continues with the current logged in user-id. The reconnect doesn't make a logout and login with earlier LinkedIn created user-id.

I have a situation where a user earlier logged in with LinkedIn, is created with a new user-id with the email in LinkedIn account.
We then get the LinkedIn profile and save it locally, in models/loginregister.php: autocreateUser: using the profile gotten with $provider->profile->fetchProfile
If the user tries to log into this same LinkedIn profile from another account (another email), the user map now points to this new account userid. But we lose the earlier save profile data as it is on the earlier (linked in auto create) user id.
- Is there a way to merge the two accounts with different email-ids?
- Or should we just logout, so when user logins with LinkedIn account: it shows the proper user-id and information.
- Is there a place in login flow, like autocreateUser in registration, where we can fetch the profile and store data in database for the new user-id
- I have not seen the user data stored in the jfbconnect database: is there a table where I should be looking? Currently we are using tables from another component.

Best wishes and thanks,
Pawan.
The topic has been locked.
Support Specialist

- Is there a way to merge the two accounts with different email-ids?

We have no way to merge accounts. There's no way for JFBConnect to know which information is 'right' and which information should be overwritten.

- Or should we just logout, so when user logins with LinkedIn account: it shows the proper user-id and information.

I'm not exactly sure what you mean by logging out and how that fixes things, but since there's no way to merge, if this method is something that works for you, I'd recommend trying it.

- Is there a place in login flow, like autocreateUser in registration, where we can fetch the profile and store data in database for the new user-id

We have the Custom DB social profile plugin which is installed with JFBConnect. Using that, you can setup how to store user profile information into a custom database table. You don't need to edit our files to do this. Once enabled, you can configure it in the Profiles configuration area of JFBConnect.

- I have not seen the user data stored in the jfbconnect database: is there a table where I should be looking? Currently we are using tables from another component.

JFBConnect doesn't have a profile database table. All information stored is either in a 3rd party extension or a custom database table, as noted above. JFBConnect isn't a profile extension. There's enough of those out there that focus on creating profiles for users that it's not something we plan to implement again.

I hope that helps,
Alex
The topic has been locked.
Active Subscriptions:

None
Alex,
We are using Easyjobs extension tables to store user profile. I wanted to know a flow during login analogous to autocreate during register :where profile of the user can be asked from LinkedIn, and then we could use our routines to save the data. This will help us to keep the data as we are sometimes not able to capture user profile where user registers first with normal procedure and then uses LinkedIn, and these merge into same user id (for same email).


About this custom DB plugin: can you be more specific and send across the link for the extension that we can install?

Thanks,
Pawan.
The topic has been locked.
Support Specialist
The CustomDB plugin is installed with JFBConnect. Simply enable it in the Plugin Manager: Social Profiles - Custom DB.

Then, configure in the JFBConnect -> Profiles area. You'll need to specify the database information you want to use (if other than the standard Joomla database) and the table to store a user's profile information in. This could be an Easyjobs table or your own custom table. Once you have the table information setup, hit "Save" and let the page reload. You should be able to see the different columns from the table you selected and choose what profile information is imported into those columns for the user.

I hope that helps explain, but if you need anything else, just let me know.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
11 years 9 months ago - 11 years 9 months ago #46744 by pawan.m
Alex,
I checked the custom db: it doesn't understand insides of education and certification fields (rather treating the profile fields of education.0, 1, 2 as separate records).
I am able to get and save the $profile = $provider->profile->fetchProfile in $loginSuccess condition of login controller.

However I am getting the following error from LinkedIn, maybe because access token is used again (?):
Error code 404 received requesting data: { "errorCode": 0, "message": "Could not find person based on: ", "requestId": "XD59QHNONO", "status": 404, "timestamp": 1409311857224 }
- How do we correct this error: I have seeen this error sometimes on login earlier also
- Also is there a way to suppress this message from showing (can you tell where this is enqueued so I can comment it)? I am seeing it to be a benign error, i.e. it doesn;t affect the end user functionality: is that right?

Best wishes,
Pawan.
Last edit: 11 years 9 months ago by pawan.m.
The topic has been locked.
Support Specialist

I checked the custom db: it doesn't understand insides of education and certification fields (rather treating the profile fields of education.0, 1, 2 as separate records).

Correct. That's how our LinkedIn integration works, we have separate data for each of the education fields because most fields that are imported to are simple text-type fields. If you have a special format you want it in, you'll need to use the fetchProfile call like you seem to be doing.

However I am getting the following error from LinkedIn, maybe because access token is used again (?):
Error code 404 received requesting data: { "errorCode": 0, "message": "Could not find person based on: ", "requestId": "XD59QHNONO", "status": 404, "timestamp": 1409311857224 }
- How do we correct this error: I have seeen this error sometimes on login earlier also

The access token is meant to be used repeatedly. If no access token is being used, that would be a problem. From the error message, it looks like no user ID is being sent at all. Th error is:

"Could not find person based on: "

There is nothing after the :, which means no user ID is being sent. You'll need to determine what user ID should be used and why it isn't being set.

- Also is there a way to suppress this message from showing (can you tell where this is enqueued so I can comment it)? I am seeing it to be a benign error, i.e. it doesn;t affect the end user functionality: is that right?

If you set the "Enable Debug Mode" setting in JFBConnect to "No", that message should not display.

I hope that helps,
Alex
The topic has been locked.