plugin = $plugin; $this->user_meta = $user_meta; } /** * Hooks. */ public function hooks() { add_action( 'show_user_profile', [ $this, 'add_custom_user_fields_admin' ], 75 ); add_action( 'edit_user_profile', [ $this, 'add_custom_user_fields_admin' ], 75 ); add_action( 'personal_options_update', [ $this, 'save_custom_user_fields_admin' ] ); add_action( 'edit_user_profile_update', [ $this, 'save_custom_user_fields_admin' ] ); } /** * Add custom fields to edit user admin /wp-admin/profile.php. * * @param mixed $user . * * @return void */ public function add_custom_user_fields_admin( $user ) { $settings = $this->plugin->get_settings(); $sections = $this->plugin->sections; if ( ! $settings ) { return; } foreach ( $settings as $key => $type ) { if ( ! $this->user_meta->is_fcf_section( $key ) || ! $this->user_meta->is_section_allowed_for_usermeta( $key ) || ! is_array( $type ) ) { continue; } $section_data = $sections[ $key ] ?? ( $sections[ 'woocommerce_' . $key ] ?? null ); if ( $section_data === null ) { continue; } echo '