本文整理汇总了PHP中wp_get_current_user函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_current_user函数的具体用法?PHP wp_get_current_user怎么用?PHP wp_get_current_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_current_user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: load_user
public function load_user()
{
if ($this->id > 0) {
$current_user = get_user_by('ID', $this->id);
} elseif (function_exists('is_user_logged_in') && is_user_logged_in()) {
$current_user = wp_get_current_user();
}
if (isset($current_user) && $current_user) {
$this->id = $current_user->ID;
$this->first_name = $current_user->user_firstname;
$this->last_name = $current_user->user_lastname;
$this->email = $current_user->user_email;
$this->address = get_user_meta($current_user->ID, 'address', TRUE);
$this->is_on_mailing_list = get_user_meta($current_user->ID, 'mailing_list', TRUE);
$this->is_on_mailing_list = $this->is_on_mailing_list == 1 ? TRUE : FALSE;
$neighborhood_id = get_user_meta($current_user->ID, 'neighborhood_id', TRUE);
if (!empty($neighborhood_id) && $neighborhood_id > 0) {
$args = array('post_type' => 'wbb_neighborhood', 'post_status' => 'publish');
$query = new \WP_Query($args);
while ($query->have_posts()) {
$query->the_post();
if (get_the_ID() == $neighborhood_id) {
$this->neighborhood = new Neighborhood();
$this->neighborhood->post_id = get_the_ID();
$this->neighborhood->title = get_the_title();
break;
}
}
}
$this->get_locations();
}
}
开发者ID:TonyDeStefano,项目名称:Walk-Bike-Bus-Plugin,代码行数:32,代码来源:User.php
示例2: create_listings
function create_listings()
{
global $wpdb, $bp;
$current_user = wp_get_current_user();
//categories
$user_ID = $bp->displayed_user->id;
if (isset($_POST["save_bepro_listing"]) && !empty($_POST["save_bepro_listing"])) {
$success = false;
$success = bepro_listings_save();
if ($success) {
$message = urlencode("Success saving listing");
} else {
$message = urlencode("Error saving listing");
}
$current_user = wp_get_current_user();
$bp_profile_link = bp_core_get_user_domain($bp->displayed_user->id);
wp_redirect($bp_profile_link . BEPRO_LISTINGS_SLUG . "?message=" . $message);
exit;
} elseif (isset($bp->action_variables[0]) && $bp->current_action == BEPRO_LISTINGS_CREATE_SLUG) {
add_action('bp_template_content', 'update_listing_content');
} else {
add_action('bp_template_content', 'create_listing_content');
}
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
}
开发者ID:baljindersingh88,项目名称:bepro-listings,代码行数:25,代码来源:bepro-listings-bp.php
示例3: record_coupon_application
function record_coupon_application($sub_id = false, $pricing = false)
{
global $blog_id;
$global = defined('MEMBERSHIP_GLOBAL_TABLES') && filter_var(MEMBERSHIP_GLOBAL_TABLES, FILTER_VALIDATE_BOOLEAN);
// Create transient for 1 hour. This means the user has 1 hour to redeem the coupon after its been applied before it goes back into the pool.
// If you want to use a different time limit use the filter below
$time = apply_filters('membership_apply_coupon_redemption_time', HOUR_IN_SECONDS);
// Grab the user account as we should be logged in by now
$user = wp_get_current_user();
$transient_name = 'm_coupon_' . $blog_id . '_' . $user->ID . '_' . $sub_id;
$transient_value = array('coupon_id' => $this->_coupon->id, 'user_id' => $user->ID, 'sub_id' => $sub_id, 'prices_w_coupon' => $pricing);
// Check if a transient already exists and delete it if it does
if ($global && function_exists('get_site_transient')) {
$trying = get_site_transient($transient_name);
if ($trying != false) {
// We have found an existing coupon try so remove it as we are using a new one
delete_site_transient($transient_name);
}
set_site_transient($transient_name, $transient_value, $time);
} else {
$trying = get_transient($transient_name);
if ($trying != false) {
// We have found an existing coupon try so remove it as we are using a new one
delete_transient($transient_name);
}
set_transient($transient_name, $transient_value, $time);
}
}
开发者ID:vilmark,项目名称:vilmark_main,代码行数:28,代码来源:class.coupon.php
示例4: saveToStore
private function saveToStore($subject, $requestBody, $actionType)
{
$property = json_decode($requestBody);
$predicate = $property->key;
$value = $property->value;
$language = $property->lang;
$type = $property->type;
$datatype = $property->datatype;
$subject = "http://dbpedia.org/resource/{$subject}";
$predicates = array($predicate => array(array("value" => $value, "type" => $type)));
if (!empty($language)) {
$predicates[$predicate][0]["lang"] = $language;
}
if (!empty($datatype)) {
$predicates[$predicate][0]["datatype"] = $datatype;
}
$currentUser = wp_get_current_user();
$currentUserName = $currentUser->user_login;
switch ($actionType) {
case self::TYPE_DELETE:
$this->changeSetService->saveChanges($subject, $currentUserName, array(), $predicates, "User request");
break;
case self::TYPE_UPDATE:
$this->changeSetService->saveChanges($subject, $currentUserName, $predicates, array(), "User request");
break;
}
}
开发者ID:gitter-badger,项目名称:wordlift-plugin,代码行数:27,代码来源:PropertyAjaxService.php
示例5: Save_Report_Message
function Save_Report_Message()
{
$current_user = wp_get_current_user();
$email_name = $current_user->user_firstname . ' ' . $current_user->user_lastname . ' - ' . $current_user->user_email;
$date = date('Y-m-d H:i:s');
$message = $this->posts['POST_MESSAGE'];
$post = array('post_content' => $message, 'post_name' => $email_name, 'post_title' => $email_name, 'post_status' => 'publish', 'post_type' => 'collab-msg-rep', 'post_author' => get_current_user_id(), 'ping_status' => 'close', 'post_parent' => '0', 'menu_order' => '0', 'to_ping' => '', 'pinged' => '', 'post_password' => '', 'post_date' => $date, 'comment_status' => 'closed');
$page_id = wp_insert_post($post);
if (isset($this->posts['attachments']) && is_array($this->posts['attachments'])) {
update_post_meta($page_id, '_wp_collaboration_attachments', $this->posts['attachments']);
}
update_post_meta($page_id, 'Report_Id', $this->posts['Report_Id']);
/* send Emails */
$Alert_Title = get_the_author_meta('display_name', get_current_user_id()) . ' sent you a message ' . identity(array('Workroom_Id' => $this->posts['Report_Id'], 'Type' => 'Report', 'Collaborator_Id' => get_post_field('post_author', $this->posts['Report_Id'])));
$ReportAlert = new stdClass();
$ReportAlert->Collaborator_Name = get_the_author_meta('display_name', get_post_field('post_author', $this->posts['Report_Id']));
$ReportAlert->Notification_From = get_the_author_meta('display_name', get_current_user_id());
$ReportAlert->Message = nl2br($message);
ob_start();
include collaboration_plugin_dir . 'templates/frontend/emails/collaboration-report-a-problem-template.php';
$Get_Template = ob_get_clean();
ob_start();
include collaboration_plugin_dir . 'templates/frontend/emails/collaboration-email-css.php';
$css = ob_get_clean();
//Add Alert
//End Add Alerts
wp_mail('[email protected]', $Alert_Title, $css . $Get_Template);
wp_mail(get_the_author_meta('user_email', $this->posts['Report_Id']), $Alert_Title, $css . $Get_Template);
/* End send email */
//End Adding notifications and emails
echo json_encode($son);
}
开发者ID:alexsharma68,项目名称:EddCollaborationPlugin,代码行数:32,代码来源:class-collaboration.php
示例6: AtD_redirect_call
function AtD_redirect_call()
{
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$postText = trim(file_get_contents('php://input'));
}
$url = $_GET['url'];
$service = apply_filters('atd_service_domain', 'service.afterthedeadline.com');
if (defined('WPLANG')) {
if (strpos(WPLANG, 'pt') !== false) {
$service = 'pt.service.afterthedeadline.com';
} else {
if (strpos(WPLANG, 'de') !== false) {
$service = 'de.service.afterthedeadline.com';
} else {
if (strpos(WPLANG, 'es') !== false) {
$service = 'es.service.afterthedeadline.com';
} else {
if (strpos(WPLANG, 'fr') !== false) {
$service = 'fr.service.afterthedeadline.com';
}
}
}
}
}
$user = wp_get_current_user();
$guess = strcmp(AtD_get_setting($user->ID, 'AtD_guess_lang'), "true") == 0 ? "true" : "false";
$data = AtD_http_post($postText . "&guess={$guess}", defined('ATD_HOST') ? ATD_HOST : $service, $url, defined('ATD_PORT') ? ATD_PORT : 80);
header('Content-Type: text/xml');
if (!empty($data[1])) {
echo $data[1];
}
die;
}
开发者ID:Nancers,项目名称:Snancy-Website-Files,代码行数:33,代码来源:proxy.php
示例7: wppb_check_email_value
function wppb_check_email_value($message, $field, $request_data, $form_location)
{
global $wpdb;
if (isset($request_data['email']) && trim($request_data['email']) == '' && $field['required'] == 'Yes') {
return wppb_required_field_error($field["field-title"]);
}
if (isset($request_data['email']) && !is_email(trim($request_data['email']))) {
return __('The email you entered is not a valid email address.', 'profilebuilder');
}
if (is_multisite() || !is_multisite() && (isset($wppb_generalSettings['emailConfirmation']) && $wppb_generalSettings['emailConfirmation'] == 'yes')) {
$user_signup = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "signups WHERE user_email = %s", $request_data['email']));
if (!empty($user_signup)) {
return __('This email is already reserved to be used soon.', 'profilebuilder') . '<br/>' . __('Please try a different one!', 'profilebuilder');
}
}
$users = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->users} WHERE user_email = %s", $request_data['email']));
if (!empty($users)) {
if ($form_location == 'register') {
return __('This email is already in use.', 'profilebuilder') . '<br/>' . __('Please try a different one!', 'profilebuilder');
}
if ($form_location == 'edit_profile') {
$current_user = wp_get_current_user();
foreach ($users as $user) {
if ($user->ID != $current_user->ID) {
return __('This email is already in use.', 'profilebuilder') . '<br/>' . __('Please try a different one!', 'profilebuilder');
}
}
}
}
return $message;
}
开发者ID:DarussalamTech,项目名称:aims_prj,代码行数:31,代码来源:email.php
示例8: wptutsplus_remove_comments_menu_item
function wptutsplus_remove_comments_menu_item()
{
$user = wp_get_current_user();
if (!$user->has_cap('manage_options')) {
remove_menu_page('edit-comments.php');
}
}
开发者ID:baerdaniel,项目名称:MAT-wordpress,代码行数:7,代码来源:custom-admin.php
示例9: _s_hide_update_notices_all
/**
* Hide update notices for all but me
*/
function _s_hide_update_notices_all()
{
if (wp_get_current_user()->user_login !== 'sean') {
global $wp_version;
return (object) array('last_checked' => time(), 'version_checked' => $wp_version);
}
}
开发者ID:tincupdigital,项目名称:tincupdigital,代码行数:10,代码来源:core-functions.php
示例10: _mw_adminimize_change_admin_bar
/**
* Remove items in Admin Bar for current role of current active user in front end area
* Exclude Super Admin, if active
* Exclude Settings page of Adminimize
*
* @since 1.8.1 01/10/2013
*/
function _mw_adminimize_change_admin_bar()
{
// Only for users, there logged in.
if (!is_user_logged_in()) {
return;
}
// Exclude super admin.
if (_mw_adminimize_exclude_super_admin()) {
return;
}
/** @var $wp_admin_bar WP_Admin_Bar */
global $wp_admin_bar;
// Get current user data.
$user = wp_get_current_user();
if (!$user->roles[0]) {
return;
}
$user_role = $user->roles[0];
// Get Backend Admin Bar settings for the current user role.
if (is_admin()) {
$disabled_admin_bar_option_[$user_role] = _mw_adminimize_get_option_value('mw_adminimize_disabled_admin_bar_' . $user_role . '_items');
} else {
// Get Frontend Admin Bar settings for the current user role.
$disabled_admin_bar_option_[$user_role] = (array) _mw_adminimize_get_option_value('mw_adminimize_disabled_admin_bar_frontend_' . $user_role . '_items');
}
// No settings for this role, exit.
if (!$disabled_admin_bar_option_[$user_role]) {
return;
}
foreach ($disabled_admin_bar_option_[$user_role] as $admin_bar_item) {
$wp_admin_bar->remove_node($admin_bar_item);
}
}
开发者ID:domalexxx,项目名称:nashvancouver,代码行数:40,代码来源:admin-bar-items.php
示例11: meta_data
function meta_data()
{
?>
<generator><?php
echo WPFront_User_Role_Editor_Export::GENERATOR;
?>
</generator>
<version><?php
echo WPFront_User_Role_Editor_Export::VERSION;
?>
</version>
<date><?php
echo date('D, d M Y H:i:s +0000');
?>
</date>
<source><?php
bloginfo_rss('name');
?>
</source>
<source_url><?php
bloginfo_rss('url');
?>
</source_url>
<user_display_name><?php
echo cdata(wp_get_current_user()->display_name);
?>
</user_display_name>
<user_id><?php
echo wp_get_current_user()->ID;
?>
</user_id>
<?php
}
开发者ID:JulieKuehl,项目名称:auburn-agency,代码行数:33,代码来源:class-wpfront-user-role-editor-export.php
示例12: current
/**
* Returns currently loggedin user employer object
*
* @return Wpjb_Model_Employer
*/
public static function current()
{
if (self::$_current instanceof self) {
return self::$_current;
}
$current_user = wp_get_current_user();
if ($current_user->ID < 1) {
return new self();
}
$query = new Daq_Db_Query();
$object = $query->select()->from(__CLASS__ . " t")->where("user_id = ?", $current_user->ID)->limit(1)->execute();
if ($object[0]) {
self::$_current = $object[0];
return self::$_current;
}
// quick create
$object = new self();
$object->user_id = $current_user->ID;
$object->company_name = "";
$object->company_website = "";
$object->company_info = "";
$object->company_logo_ext = "";
$object->company_location = "";
$object->is_public = 0;
$object->is_active = self::ACCOUNT_ACTIVE;
$object->save();
self::$_current = $object;
return $object;
}
开发者ID:robjcordes,项目名称:nexnewwp,代码行数:34,代码来源:Employer.php
示例13: get_current_user_id
private function get_current_user_id()
{
global $current_user;
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
return $user_id;
}
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:7,代码来源:toolset-help-videos.php
示例14: rolo_add_contact
/**
* Template function for adding new contacts
* @since 0.1
*/
function rolo_add_contact()
{
$user = wp_get_current_user();
if ($user->ID) {
//TODO - Check user capabilites
//TODO - Verify nounce here
if (isset($_POST['rp_add_contact']) && $_POST['rp_add_contact'] == 'add_contact') {
$contact_id = _rolo_save_contact_fields();
if ($contact_id) {
// echo __("Contacto adicionado com sucesso.", 'rolopress');
$location = get_bloginfo('siteurl');
echo "<script type='text/javascript'>window.location = '" . $location . "';</script>";
//header("Location: $location", true, 301);
} else {
echo __("Ocorreu um erro ao inserir o contacto, por favor tente novamente.", 'rolopress');
_rolo_show_contact_fields();
// TODO - Handle Error properly
}
} elseif (isset($_POST['rp_add_notes']) && $_POST['rp_add_notes'] == 'add_notes') {
if (_rolo_save_contact_notes()) {
echo __("Comentários adicionados com sucesso.", 'rolopress');
} else {
// TODO - Handle Error properly
echo __("Ocorreu um erro ao inserir o comentário", 'rolopress');
}
} else {
_rolo_show_contact_fields();
}
}
}
开发者ID:nunomorgadinho,项目名称:SimplePhone,代码行数:34,代码来源:contact-functions.php
示例15: mur_block_editing_post
/**
* mur_block_editing_post()
*
* block post editing for different user
*/
function mur_block_editing_post()
{
$author_id_post = get_the_author_meta('ID');
$current_user = wp_get_current_user();
$author_role = $current_user->roles[0];
$author_id = $current_user->ID;
}
开发者ID:airton,项目名称:manage-user-roles,代码行数:12,代码来源:manage-user-roles.php
示例16: clonePage
/**
* Clones provided page ID
* @param int $pageId
* @return int
*/
public function clonePage($pageId)
{
$oldPost = get_post($pageId);
if (null === $oldPost) {
return 0;
}
if ('revision' === $oldPost->post_type) {
return 0;
}
$currentUser = wp_get_current_user();
$newPost = array('menu_order' => $oldPost->menu_order, 'comment_status' => $oldPost->comment_status, 'ping_status' => $oldPost->ping_status, 'post_author' => $currentUser->ID, 'post_content' => $oldPost->post_content, 'post_excerpt' => $oldPost->post_excerpt, 'post_mime_type' => $oldPost->post_mime_type, 'post_parent' => $oldPost->post_parent, 'post_password' => $oldPost->post_password, 'post_status' => $oldPost->post_status, 'post_title' => '(dup) ' . $oldPost->post_title, 'post_type' => $oldPost->post_type, 'post_date' => $oldPost->post_date, 'post_date_gmt' => get_gmt_from_date($oldPost->post_date));
$newId = wp_insert_post($newPost);
/*
* Generating unique slug
*/
if ($newPost['post_status'] == 'publish' || $newPost['post_status'] == 'future') {
$postName = wp_unique_post_slug($oldPost->post_name, $newId, $newPost['post_status'], $oldPost->post_type, $newPost['post_parent']);
$newPost = array();
$newPost['ID'] = $newId;
$newPost['post_name'] = $postName;
wp_update_post($newPost);
}
$this->cloneMeta($pageId, $newId);
$this->cloneOpData($pageId, $newId);
return $newId;
}
开发者ID:kyscastellanos,项目名称:arepa,代码行数:31,代码来源:clone_page.php
示例17: __construct
/**
* Adds event type, h5p library and timestamp to event before saving it.
*
* @param string $type
* Name of event to log
* @param string $library
* Name of H5P library affacted
*/
function __construct($type, $sub_type = NULL, $content_id = NULL, $content_title = NULL, $library_name = NULL, $library_version = NULL)
{
// Track the user who initiated the event as well
$current_user = wp_get_current_user();
$this->user = $current_user->ID;
parent::__construct($type, $sub_type, $content_id, $content_title, $library_name, $library_version);
}
开发者ID:limikael,项目名称:h5p-wordpress-plugin,代码行数:15,代码来源:class-h5p-event.php
示例18: px_verified_check_user_topic
function px_verified_check_user_topic($have_posts)
{
if (is_user_logged_in()) {
global $wp_roles;
$current_user = wp_get_current_user();
$roles = $current_user->roles;
$role = array_shift($roles);
$forum_name = single_post_title('', false);
if ($role == 'bbp_keymaster' || $role == 'bbp_moderator' || $role == 'administrator' || $role == 'editor') {
} else {
if ($role == 'px_wpba_customer' && $forum_name == 'WordPress Blog Android App' || $forum_name == 'WP Google Cloud Messaging' || $forum_name == 'Special Threads from us') {
} else {
if ($role == 'px_wpgcm_customer' && $forum_name == 'WP Google Cloud Messaging' || $forum_name == 'Special Threads from us') {
} else {
echo '<div class="bbp-template-notice"><p>Sorry, but you do not have the capability to view this forum</p></div>';
return $have_posts = null;
}
}
}
return $have_posts;
} else {
echo '<div class="bbp-template-notice"><p>Sorry, but you do not have the capability to view this topic</p></div>';
return $have_posts = null;
}
}
开发者ID:pixelartdev,项目名称:Pixelart-Verifier,代码行数:25,代码来源:px-support.php
示例19: wp_verify_nonce
/**
* Verify that correct nonce was used with time limit.
*
* The user is given an amount of time to use the token, so therefore, since the
* UID and $action remain the same, the independent variable is the time.
*
* @since 2.0.3
*
* @param string $nonce Nonce that was used in the form to verify
* @param string|int $action Should give context to what is taking place and be the same when nonce was created.
*
* @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
* 0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
*/
function wp_verify_nonce($nonce, $action = -1)
{
$nonce = (string) $nonce;
$user = wp_get_current_user();
$uid = (int) $user->ID;
if (!$uid) {
/**
* Filter whether the user who generated the nonce is logged out.
*
* @since 3.5.0
*
* @param int $uid ID of the nonce-owning user.
* @param string $action The nonce action.
*/
$uid = apply_filters('nonce_user_logged_out', $uid, $action);
}
if (empty($nonce)) {
die('<mainwp>' . base64_encode(json_encode(array('error' => 'You dont send nonce: ' . $action))) . '</mainwp>');
}
$token = wp_get_session_token();
$i = wp_nonce_tick();
// Nonce generated 0-12 hours ago
$expected = substr(wp_hash($i . '|' . $action . '|' . $uid . '|' . $token, 'nonce'), -12, 10);
if (hash_equals($expected, $nonce)) {
return 1;
}
// Nonce generated 12-24 hours ago
$expected = substr(wp_hash($i - 1 . '|' . $action . '|' . $uid . '|' . $token, 'nonce'), -12, 10);
if (hash_equals($expected, $nonce)) {
return 2;
}
// Invalid nonce
die('<mainwp>' . base64_encode(json_encode(array('error' => 'Invalid nonce. Try use: ' . $action))) . '</mainwp>');
}
开发者ID:jexmex,项目名称:mainwp-child,代码行数:48,代码来源:class-mainwp-child.php
示例20: dispatch
public function dispatch()
{
// Check there are categories available
if (count(get_terms(WPBDP_CATEGORY_TAX, array('hide_empty' => false))) == 0) {
if (current_user_can('administrator')) {
return wpbdp_render_msg(_x('There are no categories assigned to the business directory yet. You need to assign some categories to the business directory. Only admins can see this message. Regular users are seeing a message that they cannot add their listing at this time. Listings cannot be added until you assign categories to the business directory.', 'templates', 'WPBDM'), 'error');
} else {
return wpbdp_render_msg(_x('Your listing cannot be added at this time. Please try again later. If this is not the first time you see this warning, please ask the site administrator to set up one or more categories inside the Directory.', 'templates', 'WPBDM'), 'error');
}
}
// Login required?
if (wpbdp_get_option('require-login') && !is_user_logged_in()) {
return wpbdp_render('parts/login-required', array(), false);
}
if ($this->state->editing) {
$current_user = wp_get_current_user();
if (get_post($this->state->listing_id)->post_author != $current_user->ID && !current_user_can('administrator')) {
return wpbdp_render_msg(_x('You are not authorized to edit this listing.', 'templates', 'WPBDM'), 'error');
}
}
$callback = 'step_' . $this->state->step;
if (method_exists($this, $callback)) {
return call_user_func(array(&$this, $callback));
} else {
return 'STEP NOT IMPLEMENTED YET: ' . $this->state->get_step();
}
}
开发者ID:Nedick,项目名称:stzagora-website,代码行数:27,代码来源:view-submit-listing.php
注:本文中的wp_get_current_user函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论