Topic-icon Registration Full Joomla into specific User Group

Active Subscriptions:

None
Hi,

For a customer I am using JFBConnect on a Joomla 1.7 site.
On hitting the "Login with Facebook" I get into the registration form, as I setup the login to be full Joomla.

I want the new user to register and after that the new user has te be member of a specific User Group (jos_user_usergroup_map table entry).
Is that possible with JFBConnect?

When "no", how could this be achieved?

Kind Regards,
Jan Lucas
The topic has been locked.
Support Specialist
14 years 5 months ago #17295 by alzander
Jan,
What is that usergroup_map table? Is that a custom database table, or part of another extension?

There's a few ways to do what you're looking for:
1) Create a profile plugin for JFBConnect. There's an "onRegister" function which is only called when the user is registering through JFBConnect/Facebook. You could add the database update call there. This is the best/recommended way as the plugin will continue to work as you upgrade JFBConnect.
For more information on our plugins, see the documentation below:
www.sourcecoast.com/jfbconnect/docs/deve...ing-a-profile-plugin

The docs are a bit excessive for what you're looking for. You should be able to take an existing profile plugin and gut all the functions except the constructor and onRegister call and make the modifications quickly there.

2) Hack JFBConnect a little to add the insert call for the database during the registration process. This is probably a little quicker, but would need to be redone each time you upgrade JFBConnect.

Hope that helps, but if you need help, just let us know!
Alex
The topic has been locked.
Active Subscriptions:

None
14 years 5 months ago #17298 by JB_Walton
Hi Alex,

I will take a look at the plugins.
Hope it's not to difficult, as I am not a programmer myself.

By the way:
The #__user_usergroup_map is a standard Joomla table where all the mapping for all users to usergroups is done.

Thanks,

Jan
The topic has been locked.
Support Specialist
14 years 5 months ago #17301 by alzander
Sorry, didn't realize you were using Joomla 1.7. No, you absolutely should not modify that table directly. I hadn't had my coffee yet, so my thinking cap wasn't on.

I forget about the multiple groups of Joomla 1.7. Right now, we just set the user into the default registered group. Can you explain a little more about how you've configured Joomla and what you want to do? It sounds like users that register through Joomla should go to one group, and those that register through JFBConnect should go to another, correct?

Right now.. when a user registers through JFBConnect, they are being properly placed in the "Registered" (or whatever the default group is), right? If not, then something is wrong, and that would need to be fixed first before we can help you change the default group for Facebook users.

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

None
14 years 5 months ago #17315 by JB_Walton
Hi Alex,

No problem.

What we want to do is following:

We want to setup a site for Clients and Jobseekers / handymen.
We use the JSJobs component for the functionality and try to modify the functionality a little bit.

We want users to register as client or as jobseeker.
We created two usergroups (beneath the registered group): client / jobseeker
On registration we want them to choose whether they want to be registered as client or jobseeker.
Both will have different functions on the site, that's why.

We want users to be able to use their Facebook accounts at logon.
That's why we use JFBConnect.

What is happening?
A user hits the button "Login with Facebook" from JFBC.
As we want them to be registered in a spceial group we use the full Joomla user registration.
So a registration form will appear with the two choices: (connect to existing user / new registration).
In the new registration there has to be the choise for User Group (choose with radio buttons, for instance).

I hope that this is clearly explained.
Hope you can give me a hint.

Regards,

Jan
The topic has been locked.
Active Subscriptions:

None
14 years 5 months ago #17411 by JB_Walton
Hi Alex,

Any idea how to get this working?

Jan
The topic has been locked.
Support Specialist
14 years 5 months ago #17417 by alzander
Jan,
Yes, definitely some ideas. Sorry for the delay in getting back to you. I'm hoping to give you some code snippets that should do what you're looking for later today or this weekend at the latest. We just released JFBConnect v4.1, so are monitoring for critical issues with that (nothing crazy so far). We'll have something to you as soon as we can though.

In general though, what you're looking for should be pretty easily do-able with a JFBCProfile plugin, and we'll help you create one... though you'll need to test it a lot :D

Thanks,
Alex
The topic has been locked.
Support Specialist
14 years 5 months ago #17554 by alzander
Jan,
Told you we wouldn't forget about you! We created the plugin you're looking for and did an extremely quick test. You'll need to obviously test more and get it working on your site. Right now, it's hard-coded for groups. We'll likely release this plugin in the future with the ability set default groups users would go into and such, but for now, it should do what you're looking for.

To get installed, copy the text below and create the 2 files mentioned. Then, simply zip those two files and install like a normal Joomla extension. Enable the plugin, and you should be good to go... hopefully!

addtogroup.xml
	JFBConnect - Profiles - Add To Group
	SourceCoast | www.sourcecoast.com
	2012/01/02
	Copyright (C) 2010-2011 SourceCoast, LLC
	http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
	[email protected]
	www.sourcecoast.com
	4.1.0
	Profile integration for JFBConnect with Community Builder.
	
		addtogroup.php
	
	
	

addtogroup.php
settings = array('profiles_addtogroup_field_map' => '',);
        $this->_componentFolder = JPATH_SITE; // No component check necessary
        $this->_componentFile = '';
        
        parent::__construct($subject, $params);
    }

    function jfbcProfilesOnShowRegisterForm()
    {
        $groups = array();
        $groups[] = array('id' => 123, 'name' => "Group 1"); // UPDATE THIS
        $groups[] = array('id' => 456, 'name' => "Group 2"); // UPDATE THIS
        $groups[] = array('id' => 789, 'name' => "Group 3"); // UPDATE THIS
        $html = JHTML::_('select.genericlist', $groups, 'group_id', null, 'id', 'name', null);
        return $html;
    }

    function jfbcProfilesOnRegister($jUserId)
    {
         jimport('joomla.user.helper');
         $groupId = JRequest::getInt('group_id', 0);
         if ($groupId == '123' || $groupId == '456' || $groupId == '789') // UPDATE THIS
            JUserHelper::addUserToGroup($jUserId, $groupId);
    }
}

Please note the 4 lines above in the php file that say "UPDATE THIS". Those are the groups you want the user to select from. You can add as many groups as you want by just cutting and pasting the lines in the first block. The last line with the $groupId == '123' || $groupId == '456' ... is a security precaution to prevent a malicious person from passing in the Group ID for a super admin.. so you want to put in that line just the group IDs that are available to be selected with the || in between each, which means "OR" in PHP.

Hope that all makes sense. Again, tested very, very quickly... so please let us know how it goes.. good or bad!

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

None
14 years 5 months ago #17557 by JB_Walton
Hi Alex,

Thank you very much for this.
Only thing: created the two files and zipped them.
Via Extension manager in J1,7 I cannot get them installed.

Maybe I do something wrong?

Thanks,

Jan
The topic has been locked.
Active Subscriptions:

None
14 years 5 months ago #17558 by JB_Walton
Hi,

Sorry for this, but in xml file there was ".php.php".
Already installed.

Thanks again and I will test it.

Jan
The topic has been locked.