1

I need to be able to "intercept" in a way the plain text password to clone the registered user from a D9 site over to a D7 site via API. Alternatively if anyone knows a way to just migrate a D9 encrypted password to a D7, that would be helpful as well.

I've tried using the hook presave but the password in the user object is still already encrypted and if I pass that over to a D7 site it would not work in D7.

The general thing I'm trying to accomplish is cloning a D9 user upon registration over to a D7 legacy site via an API endpoint on D7.

Any thoughts on how this can be accomplished? Appreciate any ideas. Thanks!

1 Answers1

2

Was ultimately able to solved this myself. Using form alter hook and adding to submit actions with a function then getting the value from form state.

function mymodule_my_submit($form, &forms_state) {
 /* plain text password we wanted to get on submission */
$pass = $form_state->getValue('pass');
//do whatever with it
}
function mymodule_form_alter(&$form, 
  Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
 if($form_id == 'user_register_form') { 
  $form['actions']['submit']["#submit"][] = "mymodule_my_submit";
 }
}