Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: Question  (Read 972 times) previous topic - next topic

Question

Hello everyone, I am new to PHPRAD, I would like to know if there is a way to prevent a new one from registering as administrator for an application.Thank you

Re: Question

Reply #1
@Josito‍ please add the following code to your registration page in Page Event -> Action Before Add
Code: [Select]
$modeldata['role'] = 'Enter the default role you want to assign to a registered user';
and replace role with the name of your role field in the user table. After you generate your project, you can then locate this file app\views\partials\index\register.php and remove the field from it, that's all.

Re: Question

Reply #2
Thank you for your answer, I am new and I confess that I did not understand your answer well. It is simply a small application to register the participants of a poultry show. There are already exhibitors, veterinarians of the judges and me as administrator and I would like to prevent a new participant from registering as administrator and having full rights also on the application. Is there a simple way to find a solution? Thanks again


Re: Question

Reply #4
Hello willwin and thank you, studying your code I have the impression that the one who will register will have a default role and will not be able to register under anything other than the default role. I would like him to be able to choose between exhibitor, judge, vet ect but not administrator. I don't know if it will be possible. Thank you for your answers

 

Re: Question

Reply #5
@Josito‍ that is possible, the same code above should work with a little tweaking.
please add the following code to your registration page in Page Event -> Action Before Add
Code: [Select]
if(strtolower($modeldata['role']) == 'administrator'){
    $modeldata['role'] = 'Enter the default role you want to assign to a registered user'; // Or you  can cancel the registration
}
and replace the role with the name of your role field in the user table.