Firstly assuming that we are already having a ftp user in Plesk. Now fire this command from root user...
#id mridul (Assuming the existing ftp user is mridul)
this will give a output similar to below output...
# uid=10000(mridul) gid=524(psacln) groups=524(psacln)
Now note down the number 10000. We will need it later.
Now make encrypted password to use it while creating new ftp user...
# perl -e 'print crypt("password", "salt")'
Let's assume we are saving the password in variable $pass. We will need it later.
this will give a encrypted string for the give password string....
Now issue the below command to add new ftp user "rock"
# /usr/sbin/useradd -u 10000 -o -d /var/www/vhosts/example.com/ftpdirectory/rock -g psacln -s /bin/false rock
In this command we are setting the default ftp directory for user rock.
To set the password while creating the user, we can alter the command like below...
# /usr/sbin/useradd -u 10000 -o -d /var/www/vhosts/example.com/ftpdirectory/rock -g psacln -s /bin/false -p $pass rock
In the above command we are adding the encrypted password through $pass.
Hope this will help..
To use the above mentioned thing in php. Or better say, creating a ftp user in plesk via php will need super privileges to apachewhile issuing the above commands through exec() command.
I will discuss this in a diffrent article.