We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Add new user usign PHP and API issue
-
- Posts: 21
- Joined: Thu Jun 04, 2015 9:22 am
Add new user usign PHP and API issue
Hi
I want to provide free web hosting but single domain per user name and email address. so i created a package called Free. using free package, we can add only single domain.
when i add a new user using PHP and API, then it checks only user name. if user name exit, it returns already exit (error 4) otherwise it adds new user.
BUT similarly i want to check email id. i mean, if email id of new user already present with any already registered user name, then it should return "user exit code 4". but it adds new user name without checking email id.
That is my problem. How we can fix it?
I want to check user name and email id both. if both available then a user can register otherwise he should visit already exit.
in other world, a user name must have unique email id.
Please help.
I want to provide free web hosting but single domain per user name and email address. so i created a package called Free. using free package, we can add only single domain.
when i add a new user using PHP and API, then it checks only user name. if user name exit, it returns already exit (error 4) otherwise it adds new user.
BUT similarly i want to check email id. i mean, if email id of new user already present with any already registered user name, then it should return "user exit code 4". but it adds new user name without checking email id.
That is my problem. How we can fix it?
I want to check user name and email id both. if both available then a user can register otherwise he should visit already exit.
in other world, a user name must have unique email id.
Please help.
-
- Collaborator
- Posts: 783
- Joined: Mon May 11, 2015 8:43 am
- Contact:
- Os: CentOS 6x
- Web: apache + nginx
Re: Add new user usign PHP and API issue
It isn't easy to change this. You need to change some code for this. I suggest you build a website with database and save there all the usernames, emails, etc. to check if the username and email already exist.
-
- Posts: 21
- Joined: Thu Jun 04, 2015 9:22 am
Re: Add new user usign PHP and API issue
This is nice think but i will provide vestacp login details so they can easily change email id.
can you please help, i want to disable email change feature similar like user name.
we can not change user name. i also want to disable email change feature?
where i need to hide email field when you use click on edit for user, then it should not display email field.
can you please help, i want to disable email change feature similar like user name.
we can not change user name. i also want to disable email change feature?
where i need to hide email field when you use click on edit for user, then it should not display email field.
-
- Collaborator
- Posts: 783
- Joined: Mon May 11, 2015 8:43 am
- Contact:
- Os: CentOS 6x
- Web: apache + nginx
Re: Add new user usign PHP and API issue
You can edit the source code, the source code is available on Github: https://github.com/serghey-rodin/vesta and you can find it in /user/local/vesta. The web folder is the UI part There you can try to disable the email field.
-
- Posts: 21
- Joined: Thu Jun 04, 2015 9:22 am
Re: Add new user usign PHP and API issue
I think i need to update this:
With
I added && ($_SESSION['user'] == 'admin') so only admin can change email.
Also i added disabled in edit_user.html file for email field.
Thank you for your help. i think now it is working according my need.
Code: Select all
// Change contact email
if (($v_email != $_POST['v_email']) && (empty($_SESSION['error_msg']))) {
if (!filter_var($_POST['v_email'], FILTER_VALIDATE_EMAIL)) {
$_SESSION['error_msg'] = __('Please enter valid email address.');
} else {
$v_email = escapeshellarg($_POST['v_email']);
exec (VESTA_CMD."v-change-user-contact ".escapeshellarg($v_username)." ".$v_email, $output, $return_var);
check_return_code($return_var,$output);
unset($output);
}
}
Code: Select all
// Change contact email
if (($v_email != $_POST['v_email']) && ($_SESSION['user'] == 'admin') && (empty($_SESSION['error_msg']))) {
if (!filter_var($_POST['v_email'], FILTER_VALIDATE_EMAIL)) {
$_SESSION['error_msg'] = __('Please enter valid email address.');
} else {
$v_email = escapeshellarg($_POST['v_email']);
exec (VESTA_CMD."v-change-user-contact ".escapeshellarg($v_username)." ".$v_email, $output, $return_var);
check_return_code($return_var,$output);
unset($output);
}
}
Also i added disabled in edit_user.html file for email field.
Thank you for your help. i think now it is working according my need.
-
- Collaborator
- Posts: 783
- Joined: Mon May 11, 2015 8:43 am
- Contact:
- Os: CentOS 6x
- Web: apache + nginx
Re: Add new user usign PHP and API issue
The only problem you now have is when there is a new vesta update.
-
- Posts: 21
- Joined: Thu Jun 04, 2015 9:22 am
Re: Add new user usign PHP and API issue
Yes i have disabled auto update. i will update and just after i will update these files again.
Re: Add new user usign PHP and API issue
API documentation and examples:
http://vestacp.com/docs/API.pdf
CLI commands list and descriptions:
http://vestacp.com/docs/CLI.txt
-> viewtopic.php?f=18&t=12610
http://vestacp.com/docs/API.pdf
CLI commands list and descriptions:
http://vestacp.com/docs/CLI.txt
-> viewtopic.php?f=18&t=12610