I want to use encrypted password to store in the remote database of the protected script but at the same time I also need a plain text password to define a MySQL user at the subscription activation time. Here is a portion of my plugin: PHP: public function getPasswordFormat() { return SavedPassTable::PASSWORD_CRYPT; } public function onSubscriptionAdded(Am_Event $event){ $user = $event->getUser(); // 1. Check if user exists in MySQL if ($this->getPACS()->checkIfUserExists($user->login)) { // 2. If exists update the password $this->getPACS()->changePasswordDb($user->login, $pass); } else { // 3. If not exists create it $pass = $this->getDi()->savedPassTable->findSaved($user, SavedPassTable::PASSWORD_PLAIN); $this->getPACS()->createDbLogin($user->login, $pass); } } The code functions except that in my hooked function I end up with an encrypted password not a plain one...
replace return SavedPassTable::PASSWORD_CRYPT; to return SavedPassTable::PASSWORD_PLAIN; and you will be getting plain-text password.
(you will have to crypt it before using for other goals). I can recommend to use $user->pass, it is in the Wordpress password format and easy to use.
So I got the plain password in my remote DB table by using this script PHP: public function getPasswordFormat() { return SavedPassTable::PASSWORD_PLAIN; } public function onSubscriptionAdded(Am_Event $event){ $user = $event->getUser(); $pass = $this->getDi()->savedPassTable->findSaved($user, SavedPassTable::PASSWORD_PLAIN); //$pass = $user->pass; // 1. Check if user exists in MySQL if ($this->getPACS()->checkIfUserExists($user->login)) { // 2. If exists update the password $this->getPACS()->changePasswordDb($user->login, $pass); } else { // 3. If not exists create it $this->getPACS()->createDbLogin($user->login, $pass); } } But during the event when I try to access the plain password in the second function I end up with something scrambled. I understand the $user->pass in WordPress format is not plain text either. Do I have any chance to use a plain text password except for transitory times when the user actually submits it (at registration or login)? Or maybe I am wrong somewhere?
Apparently this is solving my issue PHP: $pass = $this->getDi()->savedPassTable->findSaved($user, SavedPassTable::PASSWORD_PLAIN)->pass;