Page 1 of 1

Add new user usign PHP and API issue

Posted: Wed Mar 02, 2016 7:30 pm
by www.rinku31
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.

Re: Add new user usign PHP and API issue

Posted: Thu Mar 03, 2016 8:33 am
by tjebbeke
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.

Re: Add new user usign PHP and API issue

Posted: Thu Mar 03, 2016 1:54 pm
by www.rinku31
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.

Re: Add new user usign PHP and API issue

Posted: Thu Mar 03, 2016 9:55 pm
by tjebbeke
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.

Re: Add new user usign PHP and API issue

Posted: Fri Mar 04, 2016 5:34 am
by www.rinku31
I think i need to update this:

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);
        }
    }
With

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);
        }
    }
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.

Re: Add new user usign PHP and API issue

Posted: Fri Mar 04, 2016 5:17 pm
by tjebbeke
The only problem you now have is when there is a new vesta update.

Re: Add new user usign PHP and API issue

Posted: Fri Mar 04, 2016 5:27 pm
by www.rinku31
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

Posted: Fri Sep 23, 2016 12:36 pm
by skurudo
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