Hi samoht,
If I remember correctly the user info is available in the user object immediately after the Joomla Registration is complete. So, if you use the CF_Joomla_Registration plugin and then run your code after the plugin you should easily be able to pick up the username and possibly the password. (Joomla only stores the md5hash for the password but the unencoded version is available at the point of registration.)
Once you've created the hash you can use it as you like - though personally I wouldn't store it in the user table but use a new table linked by userid.
Bob
Thanks Bob,
I'll give that a try. So that would mean use the plugin and then put my code in the OnSubmit and make sure the run order is Plugins first then OnSubmit ?
You are right about not storing in the user table - I actually do have a custom table just for the key's that will be connected by userid, but I am not sure how I will know the correct userid to put into that form since they haven't been created yet... Any ideas?
Thanks again!
Hey Bob,
I tried putting your test code in several places ("OnSubmit before sending email"; extra code before onsubmit in joomla reg plugin; extra code after onsubmit ...) but was not able to see anything dumped to the screen after submitting the form??
Where am I supposed to put this test code?
Hi samoht,
Onsubmit after is usually OK - do you have a redirect url set? That's the only reason I can think of why you wouldn't see something.
Bob
Oh, nope I have not set a redirect url.
do I need one to see it?
Hi samoht,
Well they are showing the Guest user object with user-id = 0
Is this showing up after the Joomal Registration? I would expect to see the new user info then.
Bob
PS The OnSubmit before block doesn't execute unless Send Emails is set to Yes in the General tab.
Hi samoht,
Slightly more specific question than that. If you do a test registration and have this code show up immediately after the registration does it show the new users info instead of the guest user info? You may need to change the order in the form setup so that the OnSubmit After code runs *after* the Joomla Registration PlugIn.
Bob
Hi Bob,
I've attached the form just in case I'm missing something.
immediately after registration I get only the guest results that I showed before. I assume I have something out of order. I also noticed that I have no auto generated code?? is this because I am using the reg plugin?
Thanks so much!
now I have the variables I need.
Just one quick question (dumb) question. How will I save to the db table from here?
Hi samoht,
Ah must be an object. Try $cf_just_registered->username;
Bob
Hi samoht,
$db->setQuery($query);
Bob
Bob - thanks for all the help!
everything works like a charm.
Greyhead,
I'm reading and re-reading this post since it is exactly what I'm trying to do.
I'm using either Joomla registration plugin or CB registration plugin to register folks and then I'm trying to get the new userid in order to use it to post information in other tables.
I've placed:
<?php
global $cf_just_registered;
echo "cf_just_registered: ".print_r($cf_just_registered, true)."<br /><br />";
?>
in the Onsubmit Code after email and I'm getting no output other than: cf_just_registered:
I've got the order of code being plugins 1, onsubmit 2
Can you see something else I have wrong?
Thanks.
Stan
Hi Stan,
The variables have changed, the new variables are in the last tab in the config page of the registration plugin!
Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max,
thanks. I had tried all of these as well but am having no success.
Essentially I'm trying to pull the userid during the registration process and post some new entries into other tables.
(in JomSocial there are no way to control registration well, so I'm working on a work around)
I've tried to assign variables like this:
$userid = $MyPlugins->cf_joomla_registration['id'];
$complete = $MyPlugins->cf_joomla_registration['complete'];
$reg_username = $MyPlugins->cf_joomla_registration['username'];
I didn't know if I have a syntax issue or if it was the fact that the Joomla id isn't established until after the whole registration process is done. I'm placing this code in the Onsubmit area.
Stan
Hi Stan,
Try putting your code into the OnSubmit After box and then using the Plugin Order tab to set that to run after the Autogenerated Code. That way all the variables have been set.
Don't use the CB registration plugin for JomSocial, the Joomla Registration should work OK. The first three(?) steps of the JomSocial registration are pure Joomla, only the last one writes a few things to JS tables.
Bob
Bob,
This is the code I tried (fashioned after your example)
<?php
global $cf_joomla_registration;
echo "Registered: ".print_r($cf_joomla_registration, true)."<br /><br />";
echo "Registration Info: ".print_r('$cf_joomla_registration->username', true)."<br /><br />";
?>
it is registering the user but, I'm getting this error on submitting that form:
Warning: implode() [function.implode]: Invalid arguments passed in /home/missione/public_html/libraries/joomla/database/database/mysql.php on line 538
I've been experimenting with this to see what's going on. Seems that this error is coming because I changed the order of the autogenerated code to 2 and the Onsubmit to 3. When I change it back, I don't get the error, but the value of cf_joomla_registration->userid isn't set yet (I'm assuming)
however this doesn't make sense since the "plugin" is what is establishing the registration information I thought. I'm observing the autogenerated code only to be there when there is a database table which is connected by choosing one.
Overall I'm a bit confused - but here is a summary of what I'm trying to do:
1. Register the user
2. Grab the userid created on the fly to use to post some other profile fields from the registration that I'm posting to a jomsocial table.
3. Post the data to an outside database if possible using CURL.
Now this may sound crazy, but I'm actually hoping to use the community builder plugin to do this since I'd like to store the same profile fields in the cb tables (this part I'm having no problems with) rather than using the joomla registration plugin.
The reason that I'm utilizing both CB and Jomsocial simultaneously is that as I convert a larger database over completely to Jomsocial eventually I'm still using the functionality of CB in the backend. Jomsocial currently has no way to view user's profiles from the backend, (and of course Jomsocial has limited ability to register and send emails.)
My question is whether Chrono contact can handle doing all of these things in one form utilizing plugins and extra code. It sure seems like it's built to be a workhorse. Believe me, if we can build a registration model for folks to use with JomSocial and CB (either/or or both), we'll have a lot of happy joomla customers coming to Chrono_contact. There are a lot of frustrated users out there in Jomsocial forum that are trying to get this functionality.
If you think I should start a new thread, it might be a good idea, however this thread had the most in it about grabbing userid information during registration and how to post the information to another table at the same time.
Hi Stan,
The code you are trying to use is partially correct, you have the variables in the variables tab of the plugin, But to access the registered user data you need to use:
$MyPlugins->cf_joomla_registration['user']
so for example to get the username you need:
$username = $MyPlugins->cf_joomla_registration['user']->username;
I'm preparing a new ChronoProfiler component so that we can use it here on the site, no idea when will I'm going to finish it, I wanted it 2 weeks back but have been under some pressure and load!
Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max,
Thanks for your help so much!!
Here's my latest code in the onsubmit code box (seems like I've tried a zillion combinations) :
<?php
global $username, $MyPlugins, $cf_joomla_registration;
$username = $MyPlugins->cf_joomla_registration['user']->username;
$userid = $MyPlugins->cf_joomla_registration['user']->userid;
$_POST['VolunteerID'] = '123';
$_POST['userid'] = $userid;
$_POST['username'] = $username;
?>
My order is: Plugin, Onsubmit, Autogenerated. With this I'm getting the '123' to post in my connected table but the userid and username post as blanks.
If I change the order as Bob suggested with Autogenerated second, then I get an implode error message.
In this form, I'm using the joomla registration plugin and have this enabled. It does run and populates the jos_user table. Then I have another table connected to the form. I just seem to have problems grabbing the user information. I know that I can grab the username from the form, but the userid is what is generated on the fly and that I need.
Thanks,
Stan
Hi Stan,
to get the userid you need to use:
$userid = $MyPlugins->cf_joomla_registration['user']->id;
but not
$userid = $MyPlugins->cf_joomla_registration['user']->userid;
Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max,
Thanks for keeping trying with me.
I've tried this:
<?php
global $username, $MyPlugins, $cf_joomla_registration;
$username = $MyPlugins->cf_joomla_registration['user']->username;
$userid = $MyPlugins->cf_joomla_registration['user']->id;
$_POST['VolunteerID'] = '123';
$_POST['classification'] = $userid;
$_POST['username'] = $username;
?>
with no success. The '123' posts but neither the $userid or $username. The table is linked with the form.
I think Bob may be looking at it on Friday. I appreciate all the help.
Hi Stan,
#1- please remove this line:
global $username, $MyPlugins, $cf_joomla_registration;
#2- where do you put this code ? onSubmit after or before email ?
#3- do you have a field named "classification" at your table ?
#4- is DB connection enabled ?
Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max,
I removed that line of code.
DB connection is certainly enabled.
I have been trying primarily onsubmit after email although I just tried before email and both do populate the '123' field fine.
I do have a field named classification.
Stan
Max,
I've reviewed the plugin code where the variable is set.
line 603: $MyPlugins->cf_cb_registration['user'] = $user;
We seem to have it right but for some reason I can't get a thing.
Do you have any form examples I could look at to see how others solved this?
Stan
Hi Stan,
hmm, are you using the Joomla registration plugin or the CB one ? you are referring to a CB plugin variable and we have been talking about the Joomla registration plugin one all the time!😉
this line:
$userid = $MyPlugins->cf_joomla_registration['user']->id;
should be
$userid = $MyPlugins->cf_cb_registration['user']->id;
if you are using the cb one!
Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max,
Sorry for the confusion, actually I've tried them both. I have forms with both plugins for registration that I'm trialing.
I'm going to want to use the cb one eventually. But I can't get either one to give me the userid as I register to use in another table.
Stan
Hi stan,
do you have this line at the top of the code ? its a vital one!
$MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id);
regards
MAx
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Ta Da!!!
Success feels so grand!!
Thank you, thank you Max!
I have to say I'd never seen that line of code before, but I won't forget it now!!
Stan
Hi Stan,
Great, its the line to load an instance from the plugins of the form, I should not have missed it first! 🙂
Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.