Skip to Content Skip to Menu

[SOLVED] Set default value for registration from GET parameter

  • softforge
  • softforge
  • OFFLINE
  • Posts: 129
  • Thanks: 21
  • Karma: 12
9 years 10 months ago - 9 years 10 months ago #255905 by softforge
Is it possible to dynamically set the default value for a registration field by passing a parameter in the URL or some other way?

I am using the invite plugin and it pre-fills the invite code when the invitation link is clicked which is great. Our registration form only requires the user to enter their email address to register so when a user clicks the invite link, it would be really nice to pre-fill their email address as well.

I can easily append the email address to the invite link so it looks like this:

www.domain.com/register?invite_code=123456789&email=name@domain.com

But this doesn't work.

Alternatively, is there a clever was to use CB Auto Actions to set the value as I can lookup the email address from the database using the invite code?

Many thanks

If you like our plugins, please consider writing a review on the Joomla Extension Directory or the Community Builder Directory ...
Last edit: 9 years 10 months ago by krileon.
The following user(s) said Thank You: JoaoTapuia

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
9 years 10 months ago #255911 by krileon
Yup, but you need the help of CB Auto Actions to do it. Using jQuery you can pass the GET variables to an input using [get_VARIABLE] substitutions. Example as follows.

Type: Code
Triggers: onBeforeRegisterFormDisplay
Access: Everybody
Conditional: [get_VARIABLE] Not Empty
Method: jQuery
Code:
Code:
$( '#INPUT_ID_HERE' ).val( '[get_VARIABLE]' );

So a working example with the above would be the following for the email field.

Type: Code
Triggers: onBeforeRegisterFormDisplay
Access: Everybody
Conditional: [get_email] Not Empty
Method: jQuery
Code:
Code:
$( '#email,#email__verify' ).val( '[get_email]' );

Invite code should be automatically handled by the invite field though.


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.
The following user(s) said Thank You: JoaoTapuia

Please Log in or Create an account to join the conversation.

  • softforge
  • softforge
  • OFFLINE
  • Posts: 129
  • Thanks: 21
  • Karma: 12
9 years 10 months ago #255922 by softforge
That works perfectly, thank you so much!

I have to say, CB Auto Actions may be the most powerful and flexible extension ever!!!

Thanks for all you help, have a Happy New Year! Exciting times for CB in 2015! :cheer:

If you like our plugins, please consider writing a review on the Joomla Extension Directory or the Community Builder Directory ...
The following user(s) said Thank You: nant, krileon

Please Log in or Create an account to join the conversation.

  • venecam
  • venecam
  • OFFLINE
  • Posts: 39
  • Thanks: 1
  • Karma: 0
9 years 2 months ago #269547 by venecam
This is GREAT! Thank you for this, I needed this to create custom links to fill my "referred by" field. That way a user can refer new members without the problem of the referral id misspellede or something like that. I would love to know if theres some way to make that field not editable or "locked" on that registration when using this method to avoid people changhing this field by error and making that referral invalid. Thanks!


PD: you have some kind of manual or tutorial when all the posibilities of auto actions are explained with examples etc? Thanks!

Please Log in or Create an account to join the conversation.

  • venecam
  • venecam
  • OFFLINE
  • Posts: 39
  • Thanks: 1
  • Karma: 0
9 years 2 months ago #269548 by venecam
The substitution is working but the conditional is not, I am getting the "[get_referido]" even when the link has not a value for "referido", even when clicking on default registration link on cb login module. What could be the problem?
Attachments:

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
9 years 2 months ago #269567 by krileon
It's doing that because it doesn't exist in GET. Variable substitutions will output as a literal string if they don't exist. You need to have &referido=VALUE in your URL for it to add it to the input. You can try the below conditions to see if it'll stop substituting in the raw string when the variable is missing from GET.

1. [get_VARIABLE] Not Empty
2. [get_VARIABLE] Is Not REGEXP /\[get_VARIABLE\]/

So for your case you'd have the below.

1. [get_referido] Not Empty
2. [get_referido] Is Not REGEXP /\[get_referido\]/

PD: you have some kind of manual or tutorial when all the posibilities of auto actions are explained with examples etc? Thanks!

We've the below videos and a few tutorials, but that's it. It's just a tool so documenting all of its usecases is impossible as that number is unlimited.

www.youtube.com/playlist?list=PLp0puRITgC7McQcw0Sli1qfSUQGwmflzi
www.joomlapolis.com/support/tutorials/107-use-cases (not all are CB Auto Actions)


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.
The following user(s) said Thank You: JoaoTapuia

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum