Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

Assign a value based on URL variable

  • bizguy
  • bizguy
  • OFFLINE
  • Posts: 199
  • Thanks: 32
  • Karma: 5
8 years 2 months ago #285011 by bizguy
Assign a value based on URL variable was created by bizguy
Is it possible to assign a value to a CB field based on a URL variable during registration?

I have 2 types of members on a site I am creating and I would like to automatically assign a value to a field during registration based on a variable I can include in the URL of the registration page like:
Code:
index.php/cb-registration/registers?cb_usertpe="Agent"

There are just 2 types of membership on this site, but I don't want guests selecting their type of membership on the form.

If there is a better method to achieve this, please suggest it.

Thanks.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48457
  • Thanks: 8280
  • Karma: 1443
8 years 2 months ago #285057 by krileon
Replied by krileon on topic Assign a value based on URL variable
If it's displayed on the registration form, yes. You can set the inputs value using jQuery in a Code action on the registration form display trigger. Otherwise no, because that field won't exist in the HTML form POST data.


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 or Create an account to join the conversation.

  • bizguy
  • bizguy
  • OFFLINE
  • Posts: 199
  • Thanks: 32
  • Karma: 5
8 years 2 months ago #285068 by bizguy
Replied by bizguy on topic Assign a value based on URL variable
Can the field be set to hidden to ensure registrants do not change the field value and still have this work? I tried setting the field to read only, but it could still be modified on registration.
Thanks for your help.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48457
  • Thanks: 8280
  • Karma: 1443
8 years 2 months ago #285118 by krileon
Replied by krileon on topic Assign a value based on URL variable
You can probably add the CSS Class "hidden" (without quotes) to the field in CB > Field Management to hide its row as that's a core Bootstrap 3 class. Read Only fields can still be edited during registration. Note you can not turn off registration edit for what you're wanting to work.

Your only other alternative is to use the before registration form display trigger and in a Code action with method set to jQuery grab the value from the URL and dynamically add a hidden input to the registration form. Next you need an after registration trigger that'll store that hidden input to a CB field.

Either usage should work fine, but they both are going to take some configuration. First usage should only need 1 action to populate the field. Second usage takes 2. Neither are particularly super secure as anyone could just inspect the HTML and alter the form values. Second usage is a little better than first in that regard.


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 or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum