本文整理汇总了PHP中nxt_get_current_user函数的典型用法代码示例。如果您正苦于以下问题:PHP nxt_get_current_user函数的具体用法?PHP nxt_get_current_user怎么用?PHP nxt_get_current_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nxt_get_current_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: members_can_current_user_view_post
/**
* Wrapper function for the members_can_user_view_post() function. This function checks if the currently
* logged-in user can view the content of a specific post.
*
* @since 0.2.0
* @param int $post_id The ID of the post to check.
* @return bool True if the user can view the post. False if the user cannot view the post.
*/
function members_can_current_user_view_post($post_id = '')
{
/* Get the current user object. */
$current_user = nxt_get_current_user();
/* Return the members_can_user_view_post() function, which returns true/false. */
return members_can_user_view_post($current_user->ID, $post_id);
}
示例2: confirm_delete_users
function confirm_delete_users($users)
{
$current_user = nxt_get_current_user();
if (!is_array($users)) {
return false;
}
screen_icon();
?>
<h2><?php
esc_html_e('Users');
?>
</h2>
<p><?php
_e('Transfer or delete posts and links before deleting users.');
?>
</p>
<form action="users.php?action=dodelete" method="post">
<input type="hidden" name="dodelete" />
<?php
nxt_nonce_field('ms-users-delete');
$site_admins = get_super_admins();
$admin_out = "<option value='{$current_user->ID}'>{$current_user->user_login}</option>";
foreach ($allusers = (array) $_POST['allusers'] as $key => $val) {
if ($val != '' && $val != '0') {
$delete_user = new nxt_User($val);
if (!current_user_can('delete_user', $delete_user->ID)) {
nxt_die(sprintf(__('Warning! User %s cannot be deleted.'), $delete_user->user_login));
}
if (in_array($delete_user->user_login, $site_admins)) {
nxt_die(sprintf(__('Warning! User cannot be deleted. The user %s is a network admnistrator.'), $delete_user->user_login));
}
echo "<input type='hidden' name='user[]' value='{$val}'/>\n";
$blogs = get_blogs_of_user($val, true);
if (!empty($blogs)) {
?>
<br /><fieldset><p><legend><?php
printf(__("What should be done with posts and links owned by <em>%s</em>?"), $delete_user->user_login);
?>
</legend></p>
<?php
foreach ((array) $blogs as $key => $details) {
$blog_users = get_users(array('blog_id' => $details->userblog_id));
if (is_array($blog_users) && !empty($blog_users)) {
$user_site = "<a href='" . esc_url(get_home_url($details->userblog_id)) . "'>{$details->blogname}</a>";
$user_dropdown = "<select name='blog[{$val}][{$key}]'>";
$user_list = '';
foreach ($blog_users as $user) {
if (!in_array($user->ID, $allusers)) {
$user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>";
}
}
if ('' == $user_list) {
$user_list = $admin_out;
}
$user_dropdown .= $user_list;
$user_dropdown .= "</select>\n";
?>
<ul style="list-style:none;">
<li><?php
printf(__('Site: %s'), $user_site);
?>
</li>
<li><label><input type="radio" id="delete_option0" name="delete[<?php
echo $details->userblog_id . '][' . $delete_user->ID;
?>
]" value="delete" checked="checked" />
<?php
_e('Delete all posts and links.');
?>
</label></li>
<li><label><input type="radio" id="delete_option1" name="delete[<?php
echo $details->userblog_id . '][' . $delete_user->ID;
?>
]" value="reassign" />
<?php
echo __('Attribute all posts and links to:') . '</label>' . $user_dropdown;
?>
</li>
</ul>
<?php
}
}
echo "</fieldset>";
}
}
}
submit_button(__('Confirm Deletion'), 'delete');
?>
</form>
<?php
return true;
}
示例3: _student_admin_page
/**
* Renders the student-only page showing all a list of all comments that
* they have left on other blogs on the site.
*
* @access private
* @since 0.2
*/
public function _student_admin_page()
{
global $blog_id;
$current_blog_id = $blog_id;
$student_id = nxt_get_current_user()->ID;
// Create a lookup table for blog names and URLs
$all_blogs = array();
foreach (ClassBlogs_Utils::get_all_blog_ids() as $blog_id) {
$all_blogs[$blog_id] = array('name' => ClassBlogs_NXTClass::get_blog_option($blog_id, 'blogname'), 'url' => ClassBlogs_NXTClass::get_blogaddress_by_id($blog_id));
}
// Paginate the data, restricting the data set to only comments that the
// current student wrote
$comments = array();
foreach ($this->get_sitewide_comments(false) as $comment) {
if ((int) $comment->user_id === $student_id) {
$comments[] = $comment;
}
}
$paginator = new ClassBlogs_Paginator($comments, self::COMMENTS_PER_ADMIN_PAGE);
$current_page = array_key_exists('paged', $_GET) ? absint($_GET['paged']) : 1;
?>
<div class="wrap">
<div id="icon-edit-comments" class="icon32"></div>
<h2><?php
_e('My Comments', 'classblogs');
?>
</h2>
<p>
<?php
_e("This page allows you to view all of the comments that you have left on other students' blogs.", 'classblogs');
?>
</p>
<?php
$paginator->show_admin_page_links($current_page);
?>
<table class="widefat cb-sw-comments-table" id="cb-sw-my-comments-list">
<thead>
<tr>
<th class="blog"><?php
_e('Blog', 'classblogs');
?>
</th>
<th class="post"><?php
_e('Post', 'classblogs');
?>
</th>
<th class="content"><?php
_e('Content', 'classblogs');
?>
</th>
<th class="status"><?php
_e('Status', 'classblogs');
?>
</th>
<th class="posted"><?php
_e('Date', 'classblogs');
?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<th class="blog"><?php
_e('Blog', 'classblogs');
?>
</th>
<th class="post"><?php
_e('Post', 'classblogs');
?>
</th>
<th class="content"><?php
_e('Content', 'classblogs');
?>
</th>
<th class="status"><?php
_e('Status', 'classblogs');
?>
</th>
<th class="posted"><?php
_e('Date', 'classblogs');
?>
</th>
</tr>
</tfoot>
<tbody>
//.........这里部分代码省略.........
示例4: _handle_student_dashboard_widget
/**
* Handles the logic to display the student-facing admin dashboard widget
* that shows their word count for the current and previous weeks.
*
* @access private
* @since 0.1
*/
public function _handle_student_dashboard_widget()
{
$date = new DateTime();
$student_id = nxt_get_current_user()->ID;
$required_words = $this->get_option('required_weekly_words');
// Get the word count for the current and previous weeks
$current_count = $this->_get_student_word_count_for_week($student_id, $date);
$date->modify('-1 week');
$previous_count = $this->_get_student_word_count_for_week($student_id, $date);
// Display the word counts in the dashboard widget
?>
<div class="count current <?php
if ($required_words && $current_count < $required_words) {
echo 'under';
}
?>
">
<h5><?php
_e('This Week', 'classblogs');
?>
</h5>
<p><?php
echo number_format($current_count);
?>
</p>
</div>
<div class="count previous <?php
if ($required_words && $previous_count < $required_words) {
echo 'under';
}
?>
">
<h5><?php
_e('Previous Week', 'classblogs');
?>
</h5>
<p><?php
echo number_format($previous_count);
?>
</p>
</div>
<div class="clearfix"></div>
<?php
if ($required_words) {
?>
<p class="required">
<?php
_e('Words required per week', 'classblogs');
?>
<span class="quantity"><?php
echo number_format($required_words);
?>
</span>
</p>
<?php
}
?>
<?php
}
示例5: send_ping
function send_ping($sub_id = false, $level_id = false, $user_id = false)
{
$this->ping = $this->get_ping();
if (!class_exists('nxt_Http')) {
include_once ABSPATH . nxtINC . '/class-http.php';
}
$pingdata = $this->pingconstants;
if (empty($user_id)) {
$user = nxt_get_current_user();
$member = new M_Membership($user->ID);
} else {
$member = new M_Membership($user_id);
}
foreach ($pingdata as $key => $value) {
switch ($key) {
case '%blogname%':
$pingdata[$key] = get_option('blogname');
break;
case '%blogurl%':
$pingdata[$key] = get_option('home');
break;
case '%username%':
$pingdata[$key] = $member->user_login;
break;
case '%usernicename%':
$pingdata[$key] = $member->user_nicename;
break;
case '%networkname%':
$pingdata[$key] = get_site_option('site_name');
break;
case '%networkurl%':
$pingdata[$key] = get_site_option('siteurl');
break;
case '%subscriptionname%':
if (!$sub_id) {
$ids = $member->get_subscription_ids();
if (!empty($ids)) {
$sub_id = $ids[0];
}
}
if (!empty($sub_id)) {
$sub =& new M_Subscription($sub_id);
$pingdata[$key] = $sub->sub_name();
} else {
$pingdata[$key] = '';
}
break;
case '%levelname%':
if (!$level_id) {
$ids = $member->get_level_ids();
if (!empty($ids)) {
$levels = $ids[0];
}
}
if (!empty($levels->level_id)) {
$level =& new M_Level($levels->level_id);
$pingdata[$key] = $level->level_title();
} else {
$pingdata[$key] = '';
}
break;
case '%timestamp%':
$pingdata[$key] = time();
break;
default:
$pingdata[$key] = apply_filter('membership_pingfield_' . $key, '');
break;
}
}
$url = $this->ping->pingurl;
// Globally replace the values in the ping and then make it into an array to send
$pingmessage = str_replace(array_keys($pingdata), array_values($pingdata), $this->ping->pinginfo);
$pingmessage = array_map('trim', explode("\n", $pingmessage));
// make the ping message into a sendable bit of text
$pingtosend = array();
foreach ($pingmessage as $key => $value) {
$temp = explode("=", $value);
$pingtosend[$temp[0]] = $temp[1];
}
// Send the request
if (class_exists('nxt_Http')) {
$request = new nxt_Http();
switch ($this->ping->pingtype) {
case 'GET':
$url = untrailingslashit($url) . "?";
foreach ($pingtosend as $key => $val) {
if (substr($url, -1) != '?') {
$url .= "&";
}
$url .= $key . "=" . urlencode($val);
}
$result = $request->request($url, array('method' => 'GET', 'body' => ''));
break;
case 'POST':
$result = $request->request($url, array('method' => 'POST', 'body' => $pingtosend));
break;
}
/*
'headers': an array of response headers, such as "x-powered-by" => "PHP/5.2.1"
'body': the response string sent by the server, as you would see it with you web browser
//.........这里部分代码省略.........
示例6: nxt_count_posts
/**
* Count number of posts of a post type and is user has permissions to view.
*
* This function provides an efficient method of finding the amount of post's
* type a blog has. Another method is to count the amount of items in
* get_posts(), but that method has a lot of overhead with doing so. Therefore,
* when developing for 2.5+, use this function instead.
*
* The $perm parameter checks for 'readable' value and if the user can read
* private posts, it will display that for the user that is signed in.
*
* @since 2.5.0
* @link http://codex.nxtclass.org/Template_Tags/nxt_count_posts
*
* @param string $type Optional. Post type to retrieve count
* @param string $perm Optional. 'readable' or empty.
* @return object Number of posts for each status
*/
function nxt_count_posts($type = 'post', $perm = '')
{
global $nxtdb;
$user = nxt_get_current_user();
$cache_key = $type;
$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$nxtdb->posts} WHERE post_type = %s";
if ('readable' == $perm && is_user_logged_in()) {
$post_type_object = get_post_type_object($type);
if (!current_user_can($post_type_object->cap->read_private_posts)) {
$cache_key .= '_' . $perm . '_' . $user->ID;
$query .= " AND (post_status != 'private' OR ( post_author = '{$user->ID}' AND post_status = 'private' ))";
}
}
$query .= ' GROUP BY post_status';
$count = nxt_cache_get($cache_key, 'counts');
if (false !== $count) {
return $count;
}
$count = $nxtdb->get_results($nxtdb->prepare($query, $type), ARRAY_A);
$stats = array();
foreach (get_post_stati() as $state) {
$stats[$state] = 0;
}
foreach ((array) $count as $row) {
$stats[$row['post_status']] = $row['num_posts'];
}
$stats = (object) $stats;
nxt_cache_set($cache_key, $stats, 'counts');
return $stats;
}
示例7: widget
function widget($args, $instance)
{
//Get args and output the title
extract($args);
echo $before_widget;
$title = apply_filters('widget_title', $instance['title']);
if ($title) {
echo $before_title . $title . $after_title;
}
//If logged in, show "Welcome, User!"
if (is_user_logged_in()) {
?>
<div style='text-align:center'>
<?php
$userdata = nxt_get_current_user();
echo __('Welcome') . ', ' . $userdata->display_name;
?>
!<br />
<small>
<a href="<?php
echo get_option('siteurl');
?>
/nxt-admin/profile.php"><?php
_e("Edit Profile");
?>
</a> | <a href=" <?php
echo nxt_logout_url($_SERVER['REQUEST_URI']);
?>
"><?php
_e("Logout");
?>
</a>
</small>
</div>
<?php
//Otherwise, show the login form (with Facebook Connect button)
} else {
?>
<form name='loginform' id='loginform' action='<?php
echo get_option('siteurl');
?>
/nxt-login.php' method='post'>
<label>User:</label><br />
<input type='text' name='log' id='user_login' class='input' tabindex='20' /><input type='submit' name='nxt-submit' id='nxt-submit' value='Login' tabindex='23' /><br />
<label>Pass:</label><br />
<input type='password' name='pwd' id='user_pass' class='input' tabindex='21' />
<span id="forgotText"><a href="<?php
echo get_option('siteurl');
?>
/nxt-login.php?action=lostpassword" rel="nofollow" ><?php
_e('Forgot');
?>
?</a></span><br />
<?php
//echo "<input name='rememberme' type='hidden' id='rememberme' value='forever' />";
?>
<?php
echo nxt_register('', '');
?>
<input type='hidden' name='redirect_to' value='<?php
echo htmlspecialchars($_SERVER['REQUEST_URI']);
?>
' />
</form>
<?php
global $opt_jfb_hide_button;
if (!get_option($opt_jfb_hide_button)) {
jfb_output_facebook_btn();
//jfb_output_facebook_init(); This is output in nxt_footer as of 1.5.4
//jfb_output_facebook_callback(); This is output in nxt_footer as of 1.9.0
}
}
echo $after_widget;
}
示例8: bp_blogs_validate_blog_form
function bp_blogs_validate_blog_form()
{
$user = '';
if (is_user_logged_in()) {
$user = nxt_get_current_user();
}
return nxtmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);
}
示例9: nxt_create_nonce
/**
* Creates a random, one time use token.
*
* @since 2.0.3
*
* @param string|int $action Scalar value to add context to the nonce.
* @return string The one use form token
*/
function nxt_create_nonce($action = -1)
{
$user = nxt_get_current_user();
$uid = (int) $user->ID;
$i = nxt_nonce_tick();
return substr(nxt_hash($i . $action . $uid, 'nonce'), -12, 10);
}
示例10: huddle_bp_blogs_validate_blog_signup
function huddle_bp_blogs_validate_blog_signup()
{
global $nxtdb, $current_user, $blogname, $blog_title, $errors, $domain, $path, $current_site;
if (!check_admin_referer('bp_blog_signup_form')) {
return false;
}
$current_user = nxt_get_current_user();
if (!is_user_logged_in()) {
die;
}
$result = bp_blogs_validate_blog_form();
extract($result);
if ($errors->get_error_code()) {
unset($_POST['submit']);
huddle_bp_show_blog_signup_form($blogname, $blog_title, $errors);
return false;
}
$public = (int) $_POST['blog_public'];
$meta = apply_filters('signup_create_blog_meta', array('lang_id' => 1, 'public' => $public));
// depreciated
$meta = apply_filters('add_signup_meta', $meta);
// If this is a subdomain install, set up the site inside the root domain.
if (is_subdomain_install()) {
$domain = $blogname . '.' . preg_replace('|^www\\.|', '', $current_site->domain);
}
nxtmu_create_blog($domain, $path, $blog_title, $current_user->id, $meta, $nxtdb->siteid);
bp_blogs_confirm_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta);
return true;
}
示例11: setup_globals
function setup_globals()
{
global $bp;
/** Database **********************************************************/
// Get the base database prefix
if (empty($bp->table_prefix)) {
$bp->table_prefix = bp_core_get_table_prefix();
}
// The domain for the root of the site where the main blog resides
if (empty($bp->root_domain)) {
$bp->root_domain = bp_core_get_root_domain();
}
// Fetches all of the core BuddyPress settings in one fell swoop
if (empty($bp->site_options)) {
$bp->site_options = bp_core_get_root_options();
}
// The names of the core NXTClass pages used to display BuddyPress content
if (empty($bp->pages)) {
$bp->pages = bp_core_get_directory_pages();
}
/** Admin Bar *********************************************************/
// Set the 'My Account' global to prevent debug notices
$bp->my_account_menu_id = false;
/** Component and Action **********************************************/
// Used for overriding the 2nd level navigation menu so it can be used to
// display custom navigation for an item (for example a group)
$bp->is_single_item = false;
// Sets up the array container for the component navigation rendered
// by bp_get_nav()
$bp->bp_nav = array();
// Sets up the array container for the component options navigation
// rendered by bp_get_options_nav()
$bp->bp_options_nav = array();
// Contains an array of all the active components. The key is the slug,
// value the internal ID of the component.
//$bp->active_components = array();
/** Basic current user data *******************************************/
// Logged in user is the 'current_user'
$current_user = nxt_get_current_user();
// The user ID of the user who is currently logged in.
$bp->loggedin_user->id = $current_user->ID;
/** Avatars ***********************************************************/
// Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar
$bp->grav_default->user = apply_filters('bp_user_gravatar_default', $bp->site_options['avatar_default']);
$bp->grav_default->group = apply_filters('bp_group_gravatar_default', $bp->grav_default->user);
$bp->grav_default->blog = apply_filters('bp_blog_gravatar_default', $bp->grav_default->user);
// Notifications Table
$bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
/**
* Used to determine if user has admin rights on current content. If the
* logged in user is viewing their own profile and wants to delete
* something, is_item_admin is used. This is a generic variable so it
* can be used by other components. It can also be modified, so when
* viewing a group 'is_item_admin' would be 'true' if they are a group
* admin, and 'false' if they are not.
*/
bp_update_is_item_admin(bp_user_has_access(), 'core');
// Is the logged in user is a mod for the current item?
bp_update_is_item_mod(false, 'core');
do_action('bp_core_setup_globals');
}
示例12: init
/**
* Set up the current user.
*
* @since 2.0.0
*/
function init()
{
nxt_get_current_user();
}
示例13: nxt_update_user
/**
* Update an user in the database.
*
* It is possible to update a user's password by specifying the 'user_pass'
* value in the $userdata parameter array.
*
* If $userdata does not contain an 'ID' key, then a new user will be created
* and the new user's ID will be returned.
*
* If current user's password is being updated, then the cookies will be
* cleared.
*
* @since 2.0.0
* @see nxt_insert_user() For what fields can be set in $userdata
* @uses nxt_insert_user() Used to update existing user or add new one if user doesn't exist already
*
* @param array $userdata An array of user data.
* @return int The updated user's ID.
*/
function nxt_update_user($userdata)
{
$ID = (int) $userdata['ID'];
// First, get all of the original fields
$user_obj = get_userdata($ID);
$user = get_object_vars($user_obj->data);
// Add additional custom fields
foreach (_get_additional_user_keys($user_obj) as $key) {
$user[$key] = get_user_meta($ID, $key, true);
}
// Escape data pulled from DB.
$user = add_magic_quotes($user);
// If password is changing, hash it now.
if (!empty($userdata['user_pass'])) {
$plaintext_pass = $userdata['user_pass'];
$userdata['user_pass'] = nxt_hash_password($userdata['user_pass']);
}
nxt_cache_delete($user['user_email'], 'useremail');
// Merge old and new fields with new fields overwriting old ones.
$userdata = array_merge($user, $userdata);
$user_id = nxt_insert_user($userdata);
// Update the cookies if the password changed.
$current_user = nxt_get_current_user();
if ($current_user->ID == $ID) {
if (isset($plaintext_pass)) {
nxt_clear_auth_cookie();
nxt_set_auth_cookie($ID);
}
}
return $user_id;
}
示例14: is_user_option_local
/**
* Check whether a usermeta key has to do with the current blog.
*
* @since MU
* @uses nxt_get_current_user()
*
* @param string $key
* @param int $user_id Optional. Defaults to current user.
* @param int $blog_id Optional. Defaults to current blog.
* @return bool
*/
function is_user_option_local($key, $user_id = 0, $blog_id = 0)
{
global $nxtdb;
$current_user = nxt_get_current_user();
if ($user_id == 0) {
$user_id = $current_user->ID;
}
if ($blog_id == 0) {
$blog_id = $nxtdb->blogid;
}
$local_key = $nxtdb->base_prefix . $blog_id . '_' . $key;
if (isset($current_user->{$local_key})) {
return true;
}
return false;
}
示例15: jfb_debug_nonce_components
function jfb_debug_nonce_components()
{
global $opt_jfb_generated_nonce;
$user = nxt_get_current_user();
$uid = (int) $user->id;
$nonce_life = apply_filters('nonce_life', 86400);
$time = time();
$nonce_tick = ceil(time() / ($nonce_life / 2));
$tick_verify = nxt_nonce_tick();
$hash = nxt_hash($i . $action . $uid, 'nonce');
$nonce = substr($hash, -12, 10);
return "NONCE: {$nonce}, uid: {$uid}, life: {$nonce_life}, time: {$time}, tick: {$nonce_tick}, verify: {$tick_verify}, hash: {$hash}";
}