1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
<?php // phpcs:ignoreFile
namespace AutomateWoo\Event_Helpers;
/** * @class User_Registration */ class User_Registration { /** @var bool */ static $_created_via_ultimate_members_signup = false;
static function init() {
add_action( 'user_register', [ __CLASS__, 'user_created' ] );
// for ultimate trigger on account approval add_action( 'um_post_registration_approved_hook', [ __CLASS__, 'user_registered' ], 100, 1 ); add_action( 'um_after_user_is_approved', [ __CLASS__, 'user_registered' ], 100, 1 );
}
/** * User has just been saved in database * @param int $user_id */ static function user_created( $user_id ) {
// check for ultimate members signup, wait for approval if ( did_action( 'um_add_user_frontend' ) && self::$_created_via_ultimate_members_signup === false ) { self::$_created_via_ultimate_members_signup = true; // set in case another user is created in the same request return; // bail and wait for approval }
self::user_registered( $user_id ); }
/** * @param $user_id */ static function user_registered( $user_id ) {
if ( get_user_meta( $user_id, '_aw_user_registered', true ) ) { return; }
add_user_meta( $user_id, '_aw_user_registered', true );
// User is fully registered, only fires once per user do_action( 'automatewoo/user_registered', (int) $user_id ); }
}
|