debug(07-01): add debug logging to registration handler
This commit is contained in:
@@ -268,17 +268,25 @@ class DDHH_JM_Formidable {
|
||||
* @param int $form_id Form ID.
|
||||
*/
|
||||
public static function handle_registration_submission( $entry_id, $form_id ) {
|
||||
error_log('DDHH Registration: Hook fired for form ' . $form_id . ', entry ' . $entry_id);
|
||||
|
||||
// Only process our registration form
|
||||
if ( $form_id !== self::get_registration_form_id() ) {
|
||||
error_log('DDHH Registration: Wrong form ID. Expected ' . self::get_registration_form_id());
|
||||
return;
|
||||
}
|
||||
|
||||
error_log('DDHH Registration: Processing registration form');
|
||||
|
||||
// Get entry data
|
||||
$entry = FrmEntry::getOne( $entry_id, true );
|
||||
if ( ! $entry ) {
|
||||
error_log('DDHH Registration: Failed to get entry');
|
||||
return;
|
||||
}
|
||||
|
||||
error_log('DDHH Registration: Entry retrieved successfully');
|
||||
|
||||
// Extract field values
|
||||
$email = '';
|
||||
$password = '';
|
||||
@@ -311,21 +319,28 @@ class DDHH_JM_Formidable {
|
||||
}
|
||||
}
|
||||
|
||||
error_log('DDHH Registration: email=' . $email . ', org=' . $organization_name . ', contact=' . $contact_person);
|
||||
|
||||
// Validate required fields
|
||||
if ( empty( $email ) || empty( $password ) || empty( $organization_name ) || empty( $contact_person ) ) {
|
||||
error_log('DDHH Registration: Validation failed - missing required fields');
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate passwords match
|
||||
if ( $password !== $password_confirm ) {
|
||||
error_log('DDHH Registration: Passwords do not match');
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if user already exists
|
||||
if ( email_exists( $email ) ) {
|
||||
error_log('DDHH Registration: Email already exists');
|
||||
return;
|
||||
}
|
||||
|
||||
error_log('DDHH Registration: Validation passed, creating user...');
|
||||
|
||||
// Create username from email (part before @)
|
||||
$username = sanitize_user( strstr( $email, '@', true ) );
|
||||
|
||||
@@ -351,9 +366,12 @@ class DDHH_JM_Formidable {
|
||||
|
||||
// Check for errors
|
||||
if ( is_wp_error( $user_id ) ) {
|
||||
error_log('DDHH Registration: wp_insert_user failed - ' . $user_id->get_error_message());
|
||||
return;
|
||||
}
|
||||
|
||||
error_log('DDHH Registration: User created successfully with ID ' . $user_id);
|
||||
|
||||
// Store organization name as user meta
|
||||
update_user_meta( $user_id, 'ddhh_org_name', $organization_name );
|
||||
|
||||
@@ -361,6 +379,8 @@ class DDHH_JM_Formidable {
|
||||
wp_set_auth_cookie( $user_id, true );
|
||||
wp_set_current_user( $user_id );
|
||||
|
||||
error_log('DDHH Registration: User logged in, triggering redirect...');
|
||||
|
||||
// Optionally redirect (handled by JavaScript or form settings)
|
||||
do_action( 'ddhh_provider_registered', $user_id, $organization_name );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user