PluginProbe
OttoKit: All-in-One Automation Platform / 1.0.10
OttoKit: All-in-One Automation Platform v1.0.10
1.1.38 1.1.37 1.1.36 1.1.35 1.1.34 1.1.33 1.1.32 1.1.31 1.1.30 1.1.29 1.1.28 1.1.27 1.1.9 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 All 124 releases
suretriggers / functions.php

functions.php in OttoKit: All-in-One Automation Platform 1.0.10, at functions.php

77 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Global AutomatePlug Functions.
4 *
5 * @package Automateplug
6 */
7
8 /**
9 * Get or prepare user id.
10 *
11 * @return int|mixed|string|void
12 */
13 function ap_get_current_user_id() {
14
15 $user_id = get_current_user_id();
16
17 if ( $user_id ) {
18 return $user_id;
19 }
20
21 if ( ! session_id() ) { //phpcs:ignore
22 session_start(); //phpcs:ignore
23 }
24
25 if ( isset( $_SESSION['ap_user_identifier'] ) ) {
26 return $_SESSION['ap_user_identifier']; //phpcs:ignore
27 }
28
29 $ap_user_id = wp_generate_password( 16, false );
30 $_SESSION['ap_user_identifier'] = $ap_user_id; //phpcs:ignore
31
32 return $_SESSION['ap_user_identifier']; //phpcs:ignore
33
34 }
35
36 /**
37 * Get or prepare user id.
38 *
39 * @param string $email user email.
40 *
41 * @return int|mixed|string|void
42 */
43 function ap_get_user_id_from_email( $email ) {
44
45 if ( empty( $email ) || ! email_exists( $email ) ) {
46 return false;
47 }
48
49 $get_user = get_user_by( 'email', $email );
50 return $get_user->ID;
51
52 }
53
54 add_action(
55 'in_admin_header',
56 function () {
57 if ( isset( $_GET['page'] ) && 'suretriggers' === sanitize_text_field( $_GET['page'] ) ) { // phpcs:ignore
58 remove_all_actions( 'admin_notices' );
59 remove_all_actions( 'all_admin_notices' );
60 }
61 },
62 999
63 );
64
65 add_action( 'wp_login', 'suretrigger_capture_login_time', 10, 2 );
66
67 /**
68 * Login time.
69 *
70 * @param string $user_login user login.
71 * @param object $user user.
72 * @return void
73 */
74 function suretrigger_capture_login_time( $user_login, $user ) {
75 update_user_meta( $user->ID, 'st_last_login', time() );
76 }
77