From ebcc0de0aa72811c2e0055bca8e7696278d416dc Mon Sep 17 00:00:00 2001 From: Duskell Date: Thu, 19 Feb 2026 15:16:07 +0100 Subject: [PATCH] tried to add to the reg form, but doesnt work --- .../class-partnerexpo-core-user-fields.php | 51 +++++++++++++------ 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/includes/class-partnerexpo-core-user-fields.php b/includes/class-partnerexpo-core-user-fields.php index 425e0eb..1644c98 100644 --- a/includes/class-partnerexpo-core-user-fields.php +++ b/includes/class-partnerexpo-core-user-fields.php @@ -2,22 +2,24 @@ /** * Used to register custom user fields. - * - * @link https://github.com/Duskell - * @since 1.1.0 - * @package Partnerexpo_Core - * @subpackage Partnerexpo_Core/includes - * @author Juhász Levente - */ -class Partnerexpo_Core_User_Fields { +* +* @link https://github.com/Duskell +* @since 1.1.0 +* @package Partnerexpo_Core +* @subpackage Partnerexpo_Core/includes +* @author Juhász Levente +*/ +class Partnerexpo_Core_User_Fields extends Partnerexpo_Core { public function activate_fields() { - add_action( 'show_user_profile', [$this, 'add_custom_user_fields'] ); - add_action( 'edit_user_profile', [$this, 'add_custom_user_fields'] ); - add_action( 'personal_options_update', [$this, 'save_custom_user_fields'] ); - add_action( 'edit_user_profile_update', [$this, 'save_custom_user_fields'] ); - add_action( 'user_register', [$this, 'add_value_after_reg'] ); + $this->loader->add_action( 'show_user_profile', [$this, 'add_custom_user_fields'] ); + $this->loader->add_action( 'edit_user_profile', [$this, 'add_custom_user_fields'] ); + $this->loader->add_action( 'personal_options_update', [$this, 'save_custom_user_fields'] ); + $this->loader->add_action( 'edit_user_profile_update', [$this, 'save_custom_user_fields'] ); + $this->loader->add_action( 'user_register', [$this, 'add_value_after_reg'] ); + $this->loader->add_action( 'register_form', [ $this, 'registration_form' ] ); + $this->loader->add_filter( 'registration_errors', [ $this, 'registration_errors' ], 10, 3 ); } - + public function add_custom_user_fields( $user ) { $company = get_user_meta( $user->ID, 'company', true ); ?> @@ -46,6 +48,25 @@ class Partnerexpo_Core_User_Fields { } public function add_value_after_reg( $user_id ) { - update_user_meta( $user_id, 'company', sanitize_text_field( $_POST[ 'company' ] ?? '' ) ); + if ( ! empty( $_POST['company'] ) ) { + update_user_meta( $user_id, 'company', sanitize_text_field( $_POST[ 'company' ] ?? '' ) ); + } + } + + function registration_form() { + $your_content = ob_get_contents(); + $your_content = preg_replace( '/\