Admin
3 years ago
Commands
4 years ago
Db
4 years ago
Ecommerce
3 years ago
Report
4 years ago
Site
3 years ago
TrackingCode
4 years ago
Updater
4 years ago
User
3 years ago
WpStatistics
4 years ago
views
4 years ago
API.php
4 years ago
Access.php
4 years ago
AjaxTracker.php
5 years ago
Annotations.php
4 years ago
Bootstrap.php
4 years ago
Capabilities.php
4 years ago
Compatibility.php
4 years ago
Email.php
4 years ago
Installer.php
4 years ago
Logger.php
4 years ago
OptOut.php
4 years ago
Paths.php
4 years ago
PrivacyBadge.php
4 years ago
RedirectOnActivation.php
4 years ago
Referral.php
4 years ago
Roles.php
4 years ago
ScheduledTasks.php
4 years ago
Settings.php
4 years ago
Site.php
3 years ago
TrackingCode.php
4 years ago
Uninstaller.php
4 years ago
Updater.php
4 years ago
User.php
4 years ago
User.php
44 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Matomo - free/libre analytics platform |
| 4 | * |
| 5 | * @link https://matomo.org |
| 6 | * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 7 | * @package matomo |
| 8 | */ |
| 9 | |
| 10 | namespace WpMatomo; |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; // if accessed directly |
| 14 | } |
| 15 | |
| 16 | class User { |
| 17 | const USER_MAPPING_PREFIX = 'matomo-user-login-'; |
| 18 | |
| 19 | /** |
| 20 | * @api |
| 21 | */ |
| 22 | public function get_current_matomo_user_login() { |
| 23 | if ( get_current_user_id() ) { |
| 24 | return self::get_matomo_user_login( get_current_user_id() ); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | public static function get_matomo_user_login( $wp_user_id ) { |
| 29 | return get_option( self::USER_MAPPING_PREFIX . $wp_user_id ); |
| 30 | } |
| 31 | |
| 32 | public static function map_matomo_user_login( $wp_user_id, $matomo_user_login ) { |
| 33 | if ( empty( $matomo_user_login ) ) { |
| 34 | delete_option( self::USER_MAPPING_PREFIX . $wp_user_id ); |
| 35 | } else { |
| 36 | update_option( self::USER_MAPPING_PREFIX . $wp_user_id, $matomo_user_login ); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | public function uninstall() { |
| 41 | Uninstaller::uninstall_options( self::USER_MAPPING_PREFIX ); |
| 42 | } |
| 43 | } |
| 44 |