本文整理汇总了PHP中Jetpack::get_connected_user_data方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack::get_connected_user_data方法的具体用法?PHP Jetpack::get_connected_user_data怎么用?PHP Jetpack::get_connected_user_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jetpack
的用法示例。
在下文中一共展示了Jetpack::get_connected_user_data方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: track_user_linked
static function track_user_linked()
{
$user_id = get_current_user_id();
$anon_id = get_user_meta($user_id, 'jetpack_tracks_anon_id', true);
if ($anon_id) {
self::record_user_event('_aliasUser', array('anonId' => $anon_id));
delete_user_meta($user_id, 'jetpack_tracks_anon_id');
if (!headers_sent()) {
setcookie('tk_ai', 'expired', time() - 1000);
}
}
$wpcom_user_data = Jetpack::get_connected_user_data($user_id);
update_user_meta($user_id, 'jetpack_tracks_wpcom_id', $wpcom_user_data['ID']);
self::record_user_event('user_linked', array());
}
示例2: jetpack_tracks_get_identity
function jetpack_tracks_get_identity($user_id)
{
// Meta is set, and user is still connected. Use WPCOM ID
$wpcom_id = get_user_meta($user_id, 'jetpack_tracks_wpcom_id', true);
if ($wpcom_id && Jetpack::is_user_connected($user_id)) {
return array('_ut' => 'wpcom:user_id', '_ui' => $wpcom_id);
}
// User is connected, but no meta is set yet. Use WPCOM ID and set meta.
if (Jetpack::is_user_connected($user_id)) {
$wpcom_user_data = Jetpack::get_connected_user_data($user_id);
add_user_meta($user_id, 'jetpack_tracks_wpcom_id', $wpcom_user_data['ID'], true);
return array('_ut' => 'wpcom:user_id', '_ui' => $wpcom_user_data['ID']);
}
// User isn't linked at all. Fall back to anonymous ID.
$anon_id = get_user_meta($user_id, 'jetpack_tracks_anon_id', true);
if (!$anon_id) {
$anon_id = Jetpack_Tracks_Client::get_anon_id();
add_user_meta($user_id, 'jetpack_tracks_anon_id', $anon_id, false);
}
if (!isset($_COOKIE['tk_ai']) && !headers_sent()) {
setcookie('tk_ai', $anon_id);
}
return array('_ut' => 'anon', '_ui' => $anon_id);
}
示例3: jetpack_current_user_data
/**
* Gather data about the current user.
*
* @since 4.1.0
*
* @return array
*/
function jetpack_current_user_data()
{
global $current_user;
$is_master_user = $current_user->ID == Jetpack_Options::get_option('master_user');
$dotcom_data = Jetpack::get_connected_user_data();
// Add connected user gravatar to the returned dotcom_data
$avatar_data = Jetpack::get_avatar_url($dotcom_data['email']);
$dotcom_data['avatar'] = $avatar_data[0];
$current_user_data = array('isConnected' => Jetpack::is_user_connected($current_user->ID), 'isMaster' => $is_master_user, 'username' => $current_user->user_login, 'wpcomUser' => $dotcom_data, 'gravatar' => get_avatar($current_user->ID, 40), 'permissions' => array('admin_page' => current_user_can('jetpack_admin_page'), 'connect' => current_user_can('jetpack_connect'), 'disconnect' => current_user_can('jetpack_disconnect'), 'manage_modules' => current_user_can('jetpack_manage_modules'), 'network_admin' => current_user_can('jetpack_network_admin_page'), 'network_sites_page' => current_user_can('jetpack_network_sites_page'), 'edit_posts' => current_user_can('edit_posts'), 'manage_options' => current_user_can('manage_options'), 'view_stats' => current_user_can('view_stats'), 'manage_plugins' => current_user_can('install_plugins') && current_user_can('activate_plugins') && current_user_can('update_plugins') && current_user_can('delete_plugins')));
return $current_user_data;
}
示例4: jetpack_get_tracks_user_data
function jetpack_get_tracks_user_data()
{
if (!($user_data = Jetpack::get_connected_user_data())) {
return false;
}
return array('userid' => $user_data['ID'], 'username' => $user_data['login']);
}
示例5: jetpack_current_user_data
function jetpack_current_user_data()
{
global $current_user;
$is_master_user = $current_user->ID == Jetpack_Options::get_option('master_user');
$dotcom_data = Jetpack::get_connected_user_data();
$current_user_data = array('isConnected' => Jetpack::is_user_connected($current_user->ID), 'isMaster' => $is_master_user, 'username' => $current_user->user_login, 'wpcomUser' => $dotcom_data, 'gravatar' => get_avatar($current_user->ID, 40), 'permissions' => array('admin_page' => current_user_can('jetpack_admin_page'), 'connect' => current_user_can('jetpack_connect'), 'disconnect' => current_user_can('jetpack_disconnect'), 'manage_modules' => current_user_can('jetpack_manage_modules'), 'network_admin' => current_user_can('jetpack_network_admin_page'), 'network_sites_page' => current_user_can('jetpack_network_sites_page'), 'edit_posts' => current_user_can('edit_posts'), 'manage_options' => current_user_can('manage_options')));
return $current_user_data;
}
示例6: jetpack_current_user_data
function jetpack_current_user_data()
{
global $current_user;
$is_master_user = $current_user->ID == Jetpack_Options::get_option('master_user');
$dotcom_data = Jetpack::get_connected_user_data();
$current_user_data = array('isUserConnected' => Jetpack::is_user_connected($current_user->ID), 'isMasterUser' => $is_master_user, 'adminUsername' => $current_user->user_login, 'userComData' => $dotcom_data, 'gravatar' => sprintf('<a href="%s">%s</a>', get_edit_user_link($current_user->ID), get_avatar($current_user->ID, 40)));
return $current_user_data;
}