Can I use Juser Form plugin?

F.schettino

Italian
Ok, I know how use Juser Form plugin (that is very useful), but I have a form that I have to use in various situations:

Before creation of the J! account - Form used by users who belong to an administration group
1- modification of some data, without creation of the user account
2- creation of user account (setting username, password,...).

After creation of the J! account - Form used by the owner of account
3 - modification of username, password and other data.


In the case 3, I can use Juser Form plugin; in the case 1 and 2 I think I cannot, because administrator is free to create or not the account.
So I am going to use:
- Juser Form plugin - Option/Condition: return '{fabrik_soggetti___id_User_Joomla}' != null; or something similar (for case 3)
- PHP Form plugin (onAfterProcess) to check the case and code what it is necessary. (for case 1 and 2)

The question is:
- there is a trick to use Juser Form plugin in any case (1-2-3)?
or
- can I use some Joomla PHP standard code/plugin/... to create the user account (for example, some piece of Juser Form plugin)?
 
Add a radiobutton (or yesno) "don't create-user" only visible/editable by admins and use the condition: "Return false to prevent the juser plugin from running"
So something like (pseudo-code)
if ( logged-in-user == admin && {don't-create-user} == yes) ) {
return false; //don't run juser
}
else {return true;}
 
Hi, Troester.
Thank you for quick answer.

From what you say I gather that the test Option/Condition to run Juser Form plugin works just before saving the form not when the form is loaded, as I thought.
It is logical; I am a stupid (as you've already noticed in the past :oops:)

On the form I have a Button element "Create account" that sets Username, Password,... and also sets the element table__create_user = 'Yes'.
This Button is displayed only to an administrator group.

So I have to use a different test; something like:
if( '{table__create_user}' == 'Yes' or id_Joomla_user != null)
{return true;}​
else
{return false;}​

So, Juser Form plugin works on cases 2 and 3, not in case 1; this is what I need!

Is it right?
I will try and report here.
 
Sounds right.

Assuming by 'id_Joomla_user' you mean the currently logged on user ID, that would be something like !empty('{$my->id}').

So something like ...

Code:
return '{table___create_user}' == 'Yes' || !empty('{$my->id}');

-- hugh
 
Hi, Hugh.

Why
Assuming by 'id_Joomla_user' you mean the currently logged on user ID
?

I mean 'id_Joomla_user' is the id of Joomla user who's data are on the form.
So,
'{table__create_user}' == 'Yes'​
is for the case 2: administrator has just filled value for Name, Username, Password; Juser Form plugin has to create the account.

'{id_Joomla_user} != null​
is for the case 3: the user has the account and can modify or not his data (typically the password).
(Each user can access the form showing his data).

Case 1: Juser Form plugin has to work only if an administrator push the button "Create account!" that set
table__create_user= 'Yes'​

All cases seem to me managed.
 
OK, I just didn't know what it was, you didn't put curly braces round it in your example. But I don't think testing it against null will work, use the empty() test. Null is a special case in php, which a placeholder won't match.

Sent from my HTC One using Tapatalk
 
We are in need of some funding.
More details.

Thank you.

Staff online

Back
Top