[SOLVED] Setting Registration default values

13 years 5 months ago #145005 by themick88
I am trying to use POST variables to set the default value of a registration form.

I used the advice given in the following thread:

www.joomlapolis.com/component/option,com_joomlaboard/Itemid,27/func,view/id,130324/catid,100/

I created a plugin and I'm defining variables (like _DEFAULT_CITY) in the onBeforeRegisterFormDisplay function.

The problem is, I can use defined variables to set the value of a form field LABEL, the form field DESCRIPTION, but not the form field VALUE. The default value in the registration form just shows _DEFAULT_CITY, which is the value I give it in CB Admin.

Any thoughts? I tried posting my code snippit, but the forum software didn't like that.

Thanks

Post edited by: themick88, at: 2010/10/27 22:44

Post edited by: krileon, at: 2010/11/04 14:01

Please Log in to join the conversation.

13 years 4 months ago #145080 by krileon
Replied by krileon on topic Re:Setting Registration default values
Please try using the following trigger instead and confirm if resolved.

onBeforeRegisterForm

If not working then you'll probably need to develop a more complex plugin such as with the following trigger.

onBeforegetFieldRow

The above would define the string before the field is obtained so the define can be take place. Recommend reviewing CB Privacy plugin for correct usage of that trigger though as using it wrong can cause all of your fields to fail.

Post edited by: krileon, at: 2010/10/29 16:58


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.

13 years 4 months ago #145103 by themick88
Replied by themick88 on topic Re:Setting Registration default values
Thanks krileon, but that still didn't work.

On a lark, I tried ALL of the triggers and none of them replaced the default text field value with the value of the defined variable.

I even tried defining the variable outside the function, but that didn't work either.

I know the function gets called because of the echo statements appear at the top of the registration page. Also, I have the variable name set as the field label and that changes on the Registration page. Everything appears to be working, except changing the default text field value.

I've placed the plug-in in "components/com_profiler/plugin/user/". That should be OK, right?

Thanks!

Please Log in to join the conversation.

13 years 4 months ago #145104 by themick88
Replied by themick88 on topic Re:Setting Registration default values
Here is my code:
[code:1]

global $_PLUGINS;
$_PLUGINS->registerFunction( 'onBeforeRegisterForm', 'replaceEmail','getdefaultReplacer' );
DEFINE( '_DEFAULT_CITY', 'Kansas City' );

class getdefaultReplacer extends cbPluginHandler {

function replaceEmail() {
echo "replaceEmail";
//$email = cbGetParam( $_GET, 'email', null );
DEFINE( '_DEFAULT_CITY', 'Toledo' );
}
}

[/code:1]

Post edited by: themick88, at: 2010/10/29 18:18

Post edited by: themick88, at: 2010/10/29 18:20
Attachments:

Please Log in to join the conversation.

13 years 4 months ago #145114 by krileon
Replied by krileon on topic Re:Setting Registration default values
Don't know what to tell you, it either works or it don't. It appears the language replacement is applied before the trigger is fired so your define won't do anything. You could try using the below instead to set the objects value (set the default value as blank) to see if the value will add. You'll need to use the trigger onBeforeRegisterFormDisplay.

[code:1]
function onBeforeRegisterFormDisplay( $user ) {
$value = cbGetParam( $_GET, 'PARAM', null );
$user->MYFIELD = $value;
}
[/code:1]

You'll need to replace PARAM with your URL parameter and replace MYFIELD with your actual fieldname such as cb_city.

A blank user object is passed with that trigger, this is how we keep values with a users registration fails validation; we temporarily store to that object and parse its values thus the user doesn't have to re-input.


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.

13 years 4 months ago #145137 by themick88
Replied by themick88 on topic Re:Setting Registration default values
It still doesn't work. Surely somebody has solved this issue before? There are 10 to 15 posts in the forums about it, but nobody ever published the solution.

I'm actually surprised that more people haven't posted this problem... I would have thought populating default field values using a POST or GET would have been more common.

Anyway, I just can't figure it out without seeing a full example because I can't get it working with the snippet you posted.

I do think that
[code:1]$user->cb_city= "test value";[/code:1]

... seems odd. Why would setting the fieldname to a value affect the default value of the field? I would think those two things would be independent of each other, but what do I know?

I'm giving up on this for now and moving on to other issues.

Thanks again for your earlier help.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.222 seconds

Facebook Twitter LinkedIn