当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_get_current_user函数代码示例

本文整理汇总了PHP中wp_get_current_user函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_current_user函数的具体用法?PHP wp_get_current_user怎么用?PHP wp_get_current_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_get_current_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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('alexsharma68@gmail.com', $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


注:本文中的wp_get_current_user函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。