| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Charitable User Functions. |
| 5 |
* |
| 6 |
* User related functions. |
| 7 |
* |
| 8 |
* @package Charitable/Functions/User |
| 9 |
* @version 1.0.0 |
| 10 |
* @author Eric Daams |
| 11 |
* @copyright Copyright (c) 2015, Studio 164a |
| 12 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 16 |
|
| 17 |
/** |
| 18 |
* Returns a Charitable_User object for the given user. |
| 19 |
* |
| 20 |
* This will first attempt to retrieve it from the object cache to prevent duplicate objects. |
| 21 |
* |
| 22 |
* @param int $user_id |
| 23 |
* @param boolean $foce |
| 24 |
* @return Charitable_User |
| 25 |
* @since 1.0.0 |
| 26 |
*/ |
| 27 |
function charitable_get_user( $user_id, $force = false ) { |
| 28 |
$user = wp_cache_get( $user_id, 'charitable_user', $force ); |
| 29 |
|
| 30 |
if ( ! $user ) { |
| 31 |
$user = new Charitable_User( $user_id ); |
| 32 |
wp_cache_set( $user_id, $user, 'charitable_user' ); |
| 33 |
} |
| 34 |
|
| 35 |
return $user; |
| 36 |
} |