diff --git a/includes/class-partnerexpo-core-user-fields.php b/includes/class-partnerexpo-core-user-fields.php index 2d259b8..c5f7e5e 100644 --- a/includes/class-partnerexpo-core-user-fields.php +++ b/includes/class-partnerexpo-core-user-fields.php @@ -18,9 +18,9 @@ class Partnerexpo_Core_User_Fields extends Partnerexpo_Core { } private function activate_fields() { - $this->loader->add_action( 'load-profile.php', $this, 'remove_custom_user_fields' ); $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( 'user_new_form', $this, 'add_user_new_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' ); @@ -30,16 +30,63 @@ class Partnerexpo_Core_User_Fields extends Partnerexpo_Core { } - public function remove_custom_user_fields() { - remove_all_actions('show_user_profile'); - remove_all_actions('edit_user_profile'); + public function add_user_new_fields() { + wp_enqueue_media(); + ?> +
| + |
+
+
+
+
+
+
+ |
+
|---|---|
| + | + + | +
| + |
+
+
+
+
+ |
+
|---|---|
| @@ -58,13 +105,39 @@ class Partnerexpo_Core_User_Fields extends Partnerexpo_Core { if( ! current_user_can( 'edit_user', $user_id ) ) { return; } - - update_user_meta( $user_id, 'company', sanitize_text_field( $_POST[ 'company' ] ) ); + + if ( isset($_POST['company']) ) { + update_user_meta( + $user_id, + 'company', + sanitize_text_field($_POST['company']) + ); + } + if ( isset($_POST['image_attachment_id']) ) { + update_user_meta( + $user_id, + 'company_logo_attachment_id', + absint($_POST['image_attachment_id']) + ); + } } public function add_value_after_reg( $user_id ) { - if ( ! empty( $_POST['company'] ) ) { - 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'] ) + ); + } + + if ( ! empty( $_POST['image_attachment_id'] ) ) { + update_user_meta( + $user_id, + 'company_logo_attachment_id', + absint( $_POST['image_attachment_id'] ) + ); } } diff --git a/partnerexpo-core.php b/partnerexpo-core.php index 4ee49c4..7ea1cb8 100644 --- a/partnerexpo-core.php +++ b/partnerexpo-core.php @@ -9,7 +9,7 @@ * Plugin Name: PartnerExpo Core * Plugin URI: https://partnerexpo.eu * Description: A PartnerEXPO oldal belső pluginja - * Version: 1.1.6 + * Version: 1.1.7 * Author: Juhász Levente * Author URI: https://github.com/Duskell/ * License: GPL-2.0+ @@ -23,7 +23,7 @@ if ( ! defined( 'WPINC' ) ) { die; } -define( 'PARTNEREXPO_CORE_VERSION', '1.1.6' ); +define( 'PARTNEREXPO_CORE_VERSION', '1.1.7' ); function activate_partnerexpo_core() { require_once plugin_dir_path( __FILE__ ) . 'includes/class-partnerexpo-core-activator.php'; |