Skip to content

Commit 2feabd0

Browse files
committed
v 0.25.3
- fix custom hooks loading.
1 parent a86af70 commit 2feabd0

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

wpuusermetas.php

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Plugin URI: https://github.com/WordPressUtilities/wpuusermetas
77
Update URI: https://github.com/WordPressUtilities/wpuusermetas
88
Description: Simple admin for user metas
9-
Version: 0.25.2
9+
Version: 0.25.3
1010
Author: Darklg
1111
Author URI: https://darklg.me/
1212
Text Domain: wpuusermetas
@@ -24,13 +24,16 @@ class WPUUserMetas {
2424
public $settings_update;
2525
private $sections = array();
2626
private $fields = array();
27-
private $version = '0.25.2';
27+
private $version = '0.25.3';
2828
private $register_form_hook__name = 'woocommerce_register_form';
2929

3030
public function __construct() {
3131
add_action('plugins_loaded', array(&$this,
3232
'plugins_loaded'
3333
));
34+
add_action('init', array(&$this,
35+
'load_custom_hooks'
36+
));
3437
add_action('after_setup_theme', array(&$this,
3538
'load_translation'
3639
));
@@ -57,24 +60,6 @@ public function plugins_loaded() {
5760
$this->admin_hooks();
5861
}
5962

60-
$this->fields = $this->get_datas();
61-
$hooks_user_editable = array('woocommerce_edit_account_form' => 'woocommerce_edit_account_form');
62-
foreach ($this->fields as $field) {
63-
if (isset($field['user_editable_hook'])) {
64-
$hooks_user_editable[$field['user_editable_hook']] = $field['user_editable_hook'];
65-
}
66-
}
67-
68-
/* Account */
69-
foreach ($hooks_user_editable as $hook_user_editable) {
70-
add_action($hook_user_editable, array(&$this,
71-
'woocommerce_edit_account_form'
72-
));
73-
}
74-
add_action('woocommerce_save_account_details', array(&$this,
75-
'update_user_meta'
76-
), 50, 1);
77-
7863
/* Checkout */
7964
add_filter('woocommerce_checkout_fields', array(&$this, 'woocommerce_checkout_fields'), 10, 1);
8065
add_action('woocommerce_checkout_update_order_meta', array(&$this, 'checkout_update_order_meta'));
@@ -100,6 +85,26 @@ public function plugins_loaded() {
10085
add_action('woocommerce_register_post', array(&$this, 'woocommerce_register_post'), 10, 3);
10186
}
10287

88+
function load_custom_hooks() {
89+
$this->fields = $this->get_datas();
90+
$hooks_user_editable = array('woocommerce_edit_account_form' => 'woocommerce_edit_account_form');
91+
foreach ($this->fields as $field) {
92+
if (isset($field['user_editable_hook'])) {
93+
$hooks_user_editable[$field['user_editable_hook']] = $field['user_editable_hook'];
94+
}
95+
}
96+
97+
/* Account */
98+
foreach ($hooks_user_editable as $hook_user_editable) {
99+
add_action($hook_user_editable, array(&$this,
100+
'woocommerce_edit_account_form'
101+
));
102+
}
103+
add_action('woocommerce_save_account_details', array(&$this,
104+
'update_user_meta'
105+
), 50, 1);
106+
}
107+
103108
public function woocommerce_register_form() {
104109
$current_hook = current_action();
105110
foreach ($this->sections as $id => $section) {

0 commit comments

Comments
 (0)