× Joomla Facebook Connect support forum

Topic-icon semi automatic?

Active Subscriptions:

None
14 years 1 month ago #22014 by mancon
semi automatic? was created by mancon
Hi

I need something in between Automatic and Normal registration:

I don't need the user to pick a username or password since i think is ok to make them use their FB credential every time, but in the other hand I want them to choose a custom Jomsocial multi profile and fill out some extra fields.

Is this too much for a feature request or is viable?

thanks!
The topic has been locked.
Support Specialist
14 years 1 month ago #22020 by alzander
Replied by alzander on topic semi automatic?
Manuel,
That's not too crazy of a request. We hadn't had that request for JFBConnect before, but it's come up a bit with JLinked. We'll be adding the option to hide (and auto-generate) the username and password in both extensions in a future release, likely the next big one (JFBC v4.3 and JLinked v1.3).

Can you let me know what you'd like to do about the following fields that are displayed:
* Username - auto-generate something? Should be able to do something like our auto registration for (first.last or firlas)
* Password - auto-generate something, I assume.
* Name - Hide?
* Email - Hide? (This is already an option in JFBConnect)
Once we get an idea of how you want it to function, we should be able to get you some code changes to make it happen.

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

None
14 years 1 month ago #22042 by mancon
Replied by mancon on topic semi automatic?
Awesome!

* Username - auto-generate something? Should be able to do something like our auto registration for (first.last or firlas)
We use emailasusername so yes, I would be autogenerated something like first+lastname or just with a prefix like with automatic registration

* Password - auto-generate something, I assume.
Yes, it wouldn't matter since they would always login with FB

* Name - Hide?
Yes, import from FB

* Email - Hide? (This is already an option in JFBConnect)
Yup, i would hide that and use the one in FB

thank you!!
The topic has been locked.
Active Subscriptions:

None
14 years 1 month ago #22083 by mancon
Replied by mancon on topic semi automatic?
emailasuser plugin seems to works fine with JFBConnect. now theres only 2 things left:

- autogenerate a ramdom password so FB users don't have to enter one
- hide the login area on the left of the registration page, since users won't manually link their profiles.

regards!
The topic has been locked.
Support Specialist
14 years 1 month ago #22107 by alzander
Replied by alzander on topic semi automatic?
Manuel,
Sorry for the delays. Took a bit to get the info together for you. We'll definitely be adding the ability to hide username and password in a future release, but the code changes below should hopefully get you going. Hope you don't mind getting your hands a little dirty, but I'll try to be very clear on what to do.

In the /components/com_jfbconnect/views/loginregister/view.html.php file, at the very bottom, you'll find a function called _getLoginRegisterPostData(). Replace that whole block of code with:
function _getLoginRegisterPostData()
    {
        $session = JFactory::getSession();
        $postData = $session->get('postDataLoginRegister', array());

        $this->assignRef('postData', $postData);

        $loginRegisterModel = $this->getModel('LoginRegister', 'JFBConnectModel');
        $jfbcLibrary = JFBConnectFacebookLibrary::getInstance();
        $fbUserId = $jfbcLibrary->getFbUserId();
        $fbUser = $jfbcLibrary->_getUserName($fbUserId);
        $postData['username'] = $loginRegisterModel->getAutoUsername($fbUser, $fbUserId, 2);

        $this->assignRef('postDataUsername', $postData['username']);
    }
You can change the auto-username on the line toward the bottom that starts with $postData and ends with the number 2. Replace the number 2 as follows:
0 - username will be fb_12345 (the user's FB Id)
1 - first.last
2 - firlas (first 3 chars of first and last name)
With that, the username will be automatically generated, but still shown on the registration form.

Now, edit /components/com_jfbconnect/views/loginregister/tmpl/default.php. First, lets hide the username from showing. At line 68, you'll see:
<div class="label username"><label><?php echo JText::_('COM_JFBCONNECT_USERNAME') ?></label></div><input type="text" class="inputbox required" id="username" name="username" value="<?php echo $this->postDataUsername;?>" size="20" onblur="jfbc.register.checkUsernameAvailable()" /><br/>
Change that line to:
<input type="hidden" id="username" name="username" value="<?php echo $this->postDataUsername;?>" />

Then, to auto-gen and hide the password, a few lines below that, at line 76-79, you'll see:
<div class="label password"><label><?php echo JText::_('COM_JFBCONNECT_PASSWORD')?></label></div><input type="password" class="inputbox required" id="password" name="password" value="" size="20" onblur="jfbc.register.checkPassword()" /><br/>
		<div id="jfbcPasswordSuccess"></div>
                <div class="label password1"><label><?php echo JText::_('COM_JFBCONNECT_VERIFY_PASSWORD') ?></label></div><input type="password" class="inputbox required" id="password2" name="password2" value="" size="20" onblur="jfbc.register.checkPassword2()"/><br/>
                <div id="jfbcPassword2Success"></div>
Replace that with:
<?php $pass = JUserHelper::genRandomPassword(); ?>
<input type="hidden" id="password" name="password" value="<?php echo $pass; ?>" />
<input type="hidden" id="password" name="password2" value="<?php echo $pass; ?>" />

Whew. Looks like a lot, but hopefully it's not too bad. Definitely let us know how it goes and/or if you run into any issues!

Good luck,
Alex
The topic has been locked.
Active Subscriptions:

None
14 years 2 weeks ago #22900 by mancon
Replied by mancon on topic semi automatic?
It worked!

I also commented the lest login part since people won't need to associate accounts since i set it up to auto associate on email. Seems fine.

www.bcnin.com

thank you much!
The topic has been locked.
Support Specialist
14 years 2 weeks ago #22911 by alzander
Replied by alzander on topic semi automatic?
Manuel,
Glad to hear that got you going! Should you need anything else, just let us know!

Alex
The topic has been locked.
Active Subscriptions:

None
14 years 2 weeks ago #22957 by mancon
Replied by mancon on topic semi automatic?
Actually, you mention that something similar can be done with JLinked?

that would be awesome

Thanks again
The topic has been locked.
Support Specialist
14 years 2 weeks ago #22961 by alzander
Replied by alzander on topic semi automatic?
Manuel,
Similar things can be done with JLinked, but can you verify what you're looking for before we dig up the code? Specifically, I think you want:
* Username auto-generated? If so, can you let us know how you'd want it to look? We don't have the same generateUsername function in JLinked right now.
* Password fields hidden and generated for the user?
* Email can't be hidden, since we can't pull that from LinkedIn, just so you know.

Thanks,
Alex
The topic has been locked.