CB fields exchanged between two Joomla-CB websites

4 years 1 week ago #317549 by agaudin
Hello

I am thinking to connect two websites : main site with annual subscription, "subsidiary" side site for a temporary event subscription. Of course people can report manually their firstname, lastname, email, but to ease the process and avoid ambiguity (different email, different name for married women, etc.) I would like to make something like following :
- on first website, in the logged-In menu, people can click on a link ; this link connect to the register form of the second site and send usefull CB fields values (firstname, lastname, email) to the second site by a POST or a GET html method
- on the second site, with Autoaction trigger like "onAfterRegisterFormDisplay" the register form is prefulfilled with [firstname, lastname, email]
1/ Is it possible ?
2/ If yes, how to do the "send" link on the first website ?
3/ If yes, how to get the values on the second site ?

Thanx by advance

Best regards
Antoine.

Please Log in to join the conversation.

4 years 1 week ago #317552 by krileon
That's called form spoofing and CB specifically protects against that. So no you won't be able to do that. Why do you need 2 sites exactly? Is it not possible to have the features you're wanting without requiring users to duplicate their data?

Best way to do this is usually 2 sites on 1 by having different templates and menu items. They share the same database, but can have completely different looks and features due to the menu and template assignment features built into Joomla and avoids having to duplicate users data, which is annoying for users.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

4 years 1 week ago #317556 by agaudin
Hi, thanks for your answer.

I do need to have separated sites because my annual event welcomes people with subscription (for a cheaper price) and external visitors (for a more expensive price). On the main site there is also a lot of others services and I don't want to manage external visitors on it.

I didn't intent to make form spoofing - I don't want to hide second website form in first website : I want to clearly keep separated two websites with different adresses, designs and content. I just wanted to pre-fill the second form, avoiding discordances.

I thought I could use an "onAfterRegisterFormDisplay" action which preset fields values. Anyway, if not possible, not a big deal either, people can fill it manually. But for the love of art... :-D

Regards,

Antoine

Please Log in to join the conversation.

4 years 1 week ago #317563 by krileon
You can not pre-fill the form unless you specifically implement something to do that. CB will ignore POST and GET data sent to its registration page if that data did not come from itself.

I understand what you're asking now though as you're wanting to workaround that limitation using CB Auto Actions. That won't be doable since CB won't pre-fill unless the registration failed (e.g. they attempt to register, it fails due to validation, so it fills in the data they already filled in). I think the only way to do this without throwing an error is to use the below trigger.

$_PLUGINS->trigger( 'onBeforeEditATab', array( &$tabContent, &$oTab, &$user, &$postdata, $output, $formatting, $reason, $tabbed ) );

That is ran when tabs and their fields are being ran through for display. Specifically what we're interested in is $user or var3 in case of CB Auto Actions and $postdata or var4. The $reason or var7 is also important as this tells us where we are. So for example the below would just act on registration.

Global
Triggers: onBeforeEditATab
Type: Code
User: Automatic
Access: All Non-Registered Users
Conditions
1: Custom > Value: [var7] Equal To register
Action
Method: PHP
Code
$fields = array( 'username' );

foreach ( $fields as $fieldName ) {
	$fieldValue = $input->get( 'get/' . $fieldName, null, \CBLib\Registry\GetterInterface::STRING );

	if ( $fieldValue ) {
		$variables['var3']->set( $fieldName, $fieldValue );
		$variables['var4'][$fieldName] = $fieldValue;
	}
}
Parameters
Reference Variables: Variable 3 and Variable 4

This should work fine for any field. Just add more fields to the $fields variable array and it'll handle them. They're always being cleaned to a string value for additional security (CB will also check, clean, and secure on actual POST of the form but this is an extra precaution). They will also only map if the value exists in GET. So you'd just link to your other registration form with whatever information you'd like to pass to it.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

3 years 11 months ago #317840 by agaudin
Needed time to be sure to get what you have proposed. Thanx a lot again !
Antoine.
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.196 seconds

Facebook Twitter LinkedIn