| @@ -106,12 +106,30 @@ | ||
| 106 | 106 | $Winter_MVC_WDK->model('editlog_m'); |
| 107 | 107 | $Winter_MVC_WDK->editlog_m->insert(array( |
| 108 | 108 | 'user_id' => get_current_user_id(), |
| 109 | 109 | 'post_id' => $post_id, |
| 110 | - 'date' => gmdate('Y-m-d H:i:s'), | |
| 110 | + 'date' => date('Y-m-d H:i:s'), | |
| 111 | 111 | 'ip' => $_SERVER['REMOTE_ADDR'] |
| 112 | 112 | )); |
| 113 | 113 | }); |
| 114 | + | |
| 115 | + | |
| 116 | +add_action( 'init', function () { | |
| 117 | + if (substr_count($_SERVER['REQUEST_URI'], 'auto-login') && isset( $_GET['user_id'], $_GET['token'] ) ) { | |
| 118 | + $user_id = (int) $_GET['user_id']; | |
| 119 | + $token = sanitize_text_field( $_GET['token'] ); | |
| 120 | + | |
| 121 | + if ( $token == substr(md5($user_id.NONCE_KEY.'wpdirectorykit'),0,10)) { | |
| 122 | + | |
| 123 | + wp_set_auth_cookie( $user_id ); | |
| 124 | + wp_redirect( home_url() ); | |
| 125 | + exit; | |
| 126 | + } else { | |
| 127 | + wp_die( 'Wrong token.' ); | |
| 128 | + } | |
| 129 | + } | |
| 130 | +}); | |
| 131 | + | |
| 114 | 132 | |
| 115 | 133 | |
| 116 | 134 | add_filter('posts_clauses', function($clauses, $query) { |
| 117 | 135 | global $wpdb; |