Topic-icon Redirect Registration Form

Active Subscriptions:

None
8 years 3 months ago #56832 by U Can Drive
I have a different registration form that I have designed using ChronoForms which basically asks for a membership number the client already has instead of a "User Name" and then redirects them to complete a more detailed form for the database.

when someone tries to login with Facebook for the first time I've set JFBConnect to not automatically register them. As such they are taken to a page with two options, login and connect an account to the Facebook login or Register a new account.

The problem is that it uses the original Joomla! rather than mine. I have already redirected the "Register" button, but can't see how to redirect the Facebook Login Registration.

Can you please help?

Hope that wasn't too confusing.
The topic has been locked.
Support Specialist
8 years 3 months ago #56848 by alzander
Replied by alzander on topic Redirect Registration Form
What you're asking isn't confusing at all. JFBConnect has the ability to use alternative registration flows. However, right now, we currently only support a EasySocial and JomSocial for an alternative path.

To enable alternative registration flows, one of our Social Profile plugins is used to redirect the user to the correct page and pre-populate the fields with their social network information. Creating a Social Profile plugin is meant to be relatively easy if you have a developer. If you're not, then it would be much more difficult to do so.

If you simply want to redirect the user to your ChronoForms page and have the user fill out all details on their own, the following modification should work. Start by editing the /components/com_jfbconnect/controllers/login.php file. Around line 110, you'll see:
$app->redirect(JRoute::_('index.php?option=com_jfbconnect&view=loginregister&provider=' . strtolower($provider->name) . '&return=' . base64_encode($return), false));
Simply update the path option and view parameters to your Chronoform page (you can add other query parameters as necessary). Then, test that when you create the user in Chronoform that JFBConnect properly detects the new registration and adds a row in the Usermap administrator area of JFBConnect. If so, the user should be able to login with their social credentials later without issue.

I hope that helps get you started, but if you need anything else, just let us know.

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

None
8 years 2 months ago #57055 by U Can Drive
Thanks for that Alex.

It almost worked, kinda. The redirect worked perfectly, but it didn't make the link in JFBConnect until I logged out and then used the Facebook login again.
As this is really a level deeper than my usual interaction with computers I thought I'd post the code I used to replace where you mentioned above to see if I may have gotten something wrong.
$app->redirect(JRoute::_('index.php?option=com_chronoforms5&chronoform=UserRegistration&provider=' . strtolower($provider->name) . '&return=' . base64_encode($return), false));

I tried stopping after "UserRegistration" as that is the end of the web address link but it didn't work, I also tried removing the rest of the line except the "));[/code]"
This didn't work either.
The topic has been locked.
Support Specialist
8 years 2 months ago #57077 by mel
Replied by mel on topic Redirect Registration Form
In the login.php where Alex mentioned, could you copy the 3 app->setUserState calls in the else block to right before your redirect? So it will look like this:
if ($regComponent == 'jfbconnect')
{
   $app->setUserState('com_jfbconnect.registration.alternateflow', true);
   $app->setUserState('com_jfbconnect.registration.provider.name', strtolower($provider->name));
   $app->setUserState('com_jfbconnect.registration.provider.user_id', $providerUserId);

$app->redirect(JRoute::_('index.php?option=com_chronoforms5&chronoform=UserRegistration&provider=' . strtolower($provider->name) . '&return=' . base64_encode($return), false));
}

As far as that redirect link, I don't think you'll need the provider and maybe return query parameter; I think it'll most likely be ignored. But, setting the user state with those three calls will be used by our JFBConnect plugins. Let us know if this gets you any further.

-Melissa
The topic has been locked.
Active Subscriptions:

None
8 years 2 months ago #57259 by U Can Drive
Sorry my replies are so far between, I'm working on some major database forms at the moment and they seem to take up a lot of time.

I think this is the portion you are after:
if ($regComponent == 'jfbconnect')
                    $app->redirect(JRoute::_('http://ucandrive.com.au/index.php?option=com_chronoforms5&chronoform=UserRegistration&provider=' . strtolower($provider->name) . '&return=' . base64_encode($return), false));

                else
                {
                    $app->setUserState('com_jfbconnect.registration.alternateflow', true);
                    $app->setUserState('com_jfbconnect.registration.provider.name', strtolower($provider->name));
                    $app->setUserState('com_jfbconnect.registration.provider.user_id', $providerUserId);

                    $plugins = $app->triggerEvent('socialProfilesGetPlugins');
                    foreach ($plugins as $plugin)
                    {
                        if ($plugin->getName() == $regComponent)
                            $redirect = $plugin->registration_url;
                    }
The topic has been locked.
Active Subscriptions:

None
8 years 2 months ago #57260 by U Can Drive
Thought I'd put more surrounding code in just in case I missed something:
// At this point, we have nothing left to do but redirect the user to the registration page
            if (!$jUserId)
            {
                $return = $loginRegisterModel->getLoginRedirect($provider);
                $app = JFactory::getApplication();
                $regComponent = JFBCFactory::config()->get('registration_component');
                if ($regComponent == 'jfbconnect')
                    $app->redirect(JRoute::_('http://ucandrive.com.au/index.php?option=com_chronoforms5&chronoform=UserRegistration&provider=' . strtolower($provider->name) . '&return=' . base64_encode($return), false));

                else
                {
                    $app->setUserState('com_jfbconnect.registration.alternateflow', true);
                    $app->setUserState('com_jfbconnect.registration.provider.name', strtolower($provider->name));
                    $app->setUserState('com_jfbconnect.registration.provider.user_id', $providerUserId);

                    $plugins = $app->triggerEvent('socialProfilesGetPlugins');
                    foreach ($plugins as $plugin)
                    {
                        if ($plugin->getName() == $regComponent)
                            $redirect = $plugin->registration_url;
                    }
                    if ($redirect)
                        $app->redirect(JRoute::_($redirect, false));
                }
            }
        }
The topic has been locked.
Support Specialist
8 years 2 months ago #57280 by alzander
Replied by alzander on topic Redirect Registration Form
Yes, that's the proper block of code. What Melissa is recommending is to update the block so it looks like below (I've added comments above and below the changes):
// At this point, we have nothing left to do but redirect the user to the registration page 
            if (!$jUserId) 
            { 
                $return = $loginRegisterModel->getLoginRedirect($provider); 
                $app = JFactory::getApplication(); 
                $regComponent = JFBCFactory::config()->get('registration_component'); 
                if ($regComponent == 'jfbconnect') 
                {   /******* Add this { and the 3 lines below **********/
                    $app->setUserState('com_jfbconnect.registration.alternateflow', true); 
                    $app->setUserState('com_jfbconnect.registration.provider.name', strtolower($provider->name)); 
                    $app->setUserState('com_jfbconnect.registration.provider.user_id', $providerUserId); 

                    $app->redirect(JRoute::_('http://ucandrive.com.au/index.php?option=com_chronoforms5&chronoform=UserRegistration&provider=' . strtolower($provider->name) . '&return=' . base64_encode($return), false)); 
                }   /**** Add this closing } ****/
                else 
                { 
                    $app->setUserState('com_jfbconnect.registration.alternateflow', true); 
                    $app->setUserState('com_jfbconnect.registration.provider.name', strtolower($provider->name)); 
                    $app->setUserState('com_jfbconnect.registration.provider.user_id', $providerUserId); 

                    $plugins = $app->triggerEvent('socialProfilesGetPlugins'); 
                    foreach ($plugins as $plugin) 
                    { 
                        if ($plugin->getName() == $regComponent) 
                            $redirect = $plugin->registration_url; 
                    } 
                    if ($redirect) 
                        $app->redirect(JRoute::_($redirect, false)); 
                } 
            } 
        }

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