Forums

Joomla registration 'choose usergroups'

brononius 15 Feb, 2016
Hey,

Is there a way where you can select on the form the groups which you want to use for a new user?
I see that you can select this on the backend, but then the groups are 'fixed.
It would be nice in my case if the 'inputter' can select this on the initial form...
GreyHead 15 Feb, 2016
Hi brononius,

There is some general code for adding / removing users from groups in this post

You can overwrite the default parameter using code similar to Max's post here but in this case the groups are an array $form->actions_config[77]['newuser_type'] = array(. . .)

Bob
brononius 15 Feb, 2016
Do I need to insert a custom code just above the 'joomla registration'?
In my case:
<?php 
$form->actions_config[23]['newuser_type'] = array(. . .)
?>


I tried to play around with the $form, but each time, my debug rest with:

...
    [functie] => 1
....
[_PLUGINS_] => Array
        (
            [joomla_registration] => Array
                (
                    [*isRoot] => 1
                    [id] => 936
                    [name] => Testing
                    [username] => 78qs
                    [email] => test@test.be
                    [password] => $2y$10$wP28FPGzRneGV6ewICUT..18i8bW3/Ca5hOeyfR2YSDLH2X94sYo.
                    [password_clear] => 1000
                    [block] => 0
                    [sendEmail] => 1
                    [registerDate] => 2016-02-15 13:56:29
                    [lastvisitDate] => 2016-02-15 12:47:44
                    [activation] => 
                    [groups] => Array
                        (
                            [0] => 10
                            [1] => 12
                        )


Where 10/12 are the select groups in the 'joomla registration setup', not my form. :$
Functie is my select usergroup I want it to be in... (so instead of 10/12, it should be 1)
GreyHead 15 Feb, 2016
Hi brononius,

You need to add values to the array

Bob
brononius 15 Feb, 2016
I've tried some different things, but I've got the feeling that the joomla registration doesn't take my custom code into account. I would think that one of the following things should at least change it to a fix value?


$form->actions_config[23]['groups'] = array(11, 13);
$form->actions_config[23]['newuser_type'] = array(11, 13);




ps, when I add the print_r(...) commands, it shows me the results above the data Array, the first line in the debug?

Array ( [0] => 11 [1] => 13 )
Array ( [0] => 11 [1] => 13 )

brononius 15 Feb, 2016
Is it normal that in the debug, you see _PLUGIN_ > joomla_registration?
I'm just wondering if the setup id (in my example 23 is working). Looks a bit strange to see _PLUGIN_ in the debug.
GreyHead 16 Feb, 2016
Hi brononius,

Seeing _PLUGIN_ > joomla_registration is odd but normal

I've never tries to set groups this way - what do you see in the Debugger output?

Bob
brononius 16 Feb, 2016
This is my custom code, just before 'joomla registration'.
For the moment, i'm just trying to get it working. Without looking at the form field.

It works for the name (volledigenaam = voornaam + familienaam)...

<?php
$form->actions_config[28]["groups"] = array(11, 13);

$form->data['volledigenaam'] = "{$form->data['voornaam']} {$form->data['familienaam']}";
?>



This is my complete output after submit:

Array
(
    [option] => com_chronoforms5
    [chronoform] => ContactToevoegen
    [event] => submit
    [voornaam] => Test
    [familienaam] => Delatest
    [straat] => LittleStreet
    [huisnummer] => 112
    [postcode] => 9890
    [gemeente] => Asper
    [provincie] => 8
    [land] => 25
    [telefoonnummer] => 
    [email] => test@testing.com
    [geboortedatum] => 
    [geslacht] => 
    [burgelijkestaat] => 
    [kinderen] => 
    [rijksregisternummer] => 
    [beroep] => 
    [gebruikersnaam] => Testuser
    [functie] => 11
    [status] => 1
    [nota] => 
    [Submit] => Toevoegen
    [volledigenaam] => Test Delatest
    [contid] => 14
    [name] => Test Delatest
    [username] => Testuser
    [password] => 9890
    [password2] => 9890
    [_PLUGINS_] => Array
        (
            [joomla_registration] => Array
                (
                    [*isRoot] => 
                    [id] => 953
                    [name] => Test Delatest
                    [username] => Testuser
                    [email] => test@testing.com
                    [password] => $2y$10$n6G.TvHcUJLQjFADzt3IaeqASGN2mBm.lzj8SZ4EleibwNbcZkriS
                    [password_clear] => 9890
                    [block] => 
                    [sendEmail] => 0
                    [registerDate] => 2016-02-16 15:46:27
                    [lastvisitDate] => 
                    [activation] => 
                    [groups] => Array
                        (
                            [0] => 1
                        )

                    [lastResetTime] => 
                    [resetCount] => 
                    [requireReset] => 
                    [*_params] => Joomla\Registry\Registry Object
                        (
                            [data:protected] => stdClass Object
                                (
                                )

                            [separator] => .
                        )

                    [*_authGroups] => 
                    [*_authLevels] => Array
                        (
                            [0] => 1
                            [1] => 1
                        )

                    [*_authActions] => 
                    [*_errorMsg] => 
                    [*userHelper] => JUserWrapperHelper Object
                        (
                        )

                    [*_errors] => Array
                        (
                        )

                    [aid] => 0
                    [option] => com_chronoforms5
                    [chronoform] => ContactToevoegen
                    [event] => submit
                    [voornaam] => Test
                    [familienaam] => Delatest
                    [straat] => LittleStreet
                    [huisnummer] => 112
                    [postcode] => 9890
                    [gemeente] => Asper
                    [provincie] => 8
                    [land] => 25
                    [telefoonnummer] => 
                    [geboortedatum] => 
                    [geslacht] => 
                    [burgelijkestaat] => 
                    [kinderen] => 
                    [rijksregisternummer] => 
                    [beroep] => 
                    [gebruikersnaam] => Testuser
                    [functie] => 11
                    [status] => 1
                    [nota] => 
                    [Submit] => Toevoegen
                    [volledigenaam] => Test Delatest
                    [contid] => 14
                    [password2] => 9890
                    [usertype] => deprecated
                )

        )

)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
    [11] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => INSERT INTO `oni_pers_contactgegevens` (`voornaam`, `familienaam`, `straat`, `huisnummer`, `postcode`, `gemeente`, `provincie`, `land`, `telefoonnummer`, `email`, `geboortedatum`, `geslacht`, `burgelijkestaat`, `kinderen`, `rijksregisternummer`, `beroep`, `gebruikersnaam`, `functie`, `status`, `nota`) values ('Test', 'Delatest', 'LittleStreet', '112', '9890', 'Asper', '8', '25', '', 'test@testing.com', '', '', '', '', '', '', 'Testuser', '11', '1', '');
                        )

                )

        )

)
GreyHead 19 Feb, 2016
Hi brononius,

Sorry, I mistyped the name you need, It is new_usertype, not newuser_type This works OK when I test:
<?php
$form->actions_config[23]['new_usertype'] = array(11, 13);
?>

Bob
brononius 20 Feb, 2016
Cool, got this working!!!
Final code is:

$myArray = explode(',', $form->data['functie']);
$form->actions_config[28]["new_usertype"] = $myArray;


- where 'functie' is my dropdown list
- 28 the ID is of the joomla registration part.


Thanks!!!!
This topic is locked and no more replies can be posted.