checkbox.php
1 month ago
date.php
1 month ago
datetime.php
1 month ago
field.php
1 month ago
gallery.php
1 month ago
map.php
1 month ago
media-url.php
1 month ago
media.php
1 month ago
number.php
1 month ago
post.php
1 month ago
radio.php
1 month ago
repeater.php
1 month ago
select.php
1 month ago
switcher.php
1 month ago
text.php
1 month ago
time.php
1 month ago
toggle.php
1 month ago
user.php
1 month ago
user.php
24 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Wpai\AddonAPI; |
| 4 | |
| 5 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 6 | |
| 7 | class PMXI_Addon_User_Field extends PMXI_Addon_Field { |
| 8 | |
| 9 | public function beforeImport($postId, $value, $data, $logger, $rawData) { |
| 10 | // Attempt to get user by ID. |
| 11 | $user = get_user_by('id', $value); |
| 12 | if (!$user) { |
| 13 | // Attempt to get user by Login. |
| 14 | $user = get_user_by('login', $value); |
| 15 | if (!$user) { |
| 16 | // Attempt to get user by Email. |
| 17 | $user = get_user_by('email', $value); |
| 18 | } |
| 19 | } |
| 20 | // Return user id if found, otherwise return an empty string. |
| 21 | return $user ? $user->ID : ''; |
| 22 | } |
| 23 | } |
| 24 |