本文整理汇总了PHP中get_current_user_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_current_user_id函数的具体用法?PHP get_current_user_id怎么用?PHP get_current_user_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_current_user_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
if (get_current_user_id() != $this->current_user) {
wp_delete_user(get_current_user_id());
}
wp_set_current_user($this->current_user);
}
示例2: user_menu
/**
*
* Woo User Menu
*/
function user_menu()
{
$_Twoot_Woo = new Twoot_Woo();
$url = $_Twoot_Woo->shop_urls();
$user_data = get_userdata(get_current_user_id());
$avatar = get_option('show_avatars') ? '<span class="avatar">' . get_avatar(get_current_user_id(), 20) . '</span>' : '';
$tag = get_option('permalink_structure') == false ? '&' : '?';
$html = '<nav id="woo-user-menu">';
$html .= '<ul class="sf-menu clearfix">';
if (is_user_logged_in()) {
$html .= '<li class="my-account"><a href="' . $url['account_overview'] . '">' . $avatar . esc_attr__('Howdy, ', 'Twoot') . $user_data->display_name . '</a>';
$html .= '<ul>';
$html .= '<li class="account-change-pw"><a href="' . $url['account_change_pw'] . '">' . esc_attr__('Change Password', 'Twoot') . '</a></li>';
$html .= '<li class="account-edit-adress"><a href="' . $url['account_edit_adress'] . '">' . esc_attr__('Edit Address', 'Twoot') . '</a></li>';
$html .= '<li class="account-view-order"><a href="' . $url['account_view_order'] . '">' . esc_attr__('View Order', 'Twoot') . '</a></li>';
$html .= '<li class="cart"><a href="' . $url['cart'] . '">' . esc_attr__('Shopping Cart', 'Twoot') . '</a></li>';
$html .= '<li class="checkout"><a href="' . $url['checkout'] . '">' . esc_attr__('Checkout', 'Twoot') . '</a></li>';
$html .= '</ul>';
$html .= '</li>';
$html .= '<li class="logout last"><a href="' . $url['logout'] . '">' . esc_attr__('Sign Out', 'Twoot') . '</a></li>';
} else {
if (get_option('users_can_register') && get_option('woocommerce_enable_myaccount_registration') == 'yes') {
$html .= '<li class="register"><a href="' . $url['register'] . $tag . 'user_account=register">' . esc_attr__('Create Account', 'Twoot') . '</a></li>';
}
$html .= '<li class="login last"><a href="' . $url['account_overview'] . $tag . 'user_account=login">' . esc_attr__('Sign In', 'Twoot') . '</a></li>';
}
$html .= '</ul>';
$html .= '</nav>';
return $html;
}
示例3: process
/**
* Process the request
* @todo Setting for reassigning user's posts
*/
public function process()
{
// Verify the security nonce and die if it fails
if (!isset($_POST['wp_delete_user_accounts_nonce']) || !wp_verify_nonce($_POST['wp_delete_user_accounts_nonce'], 'wp_delete_user_accounts_nonce')) {
wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Request failed security check.', 'wp-delete-user-accounts')));
}
// Don't permit admins to delete their own accounts
if (current_user_can('manage_options')) {
wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Administrators cannot delete their own accounts.', 'wp-delete-user-accounts')));
}
// Get the current user
$user_id = get_current_user_id();
// Get user meta
$meta = get_user_meta($user_id);
// Delete user's meta
foreach ($meta as $key => $val) {
delete_user_meta($user_id, $key);
}
// Destroy user's session
wp_logout();
// Delete the user's account
$deleted = wp_delete_user($user_id);
if ($deleted) {
// Send success message
wp_send_json(array('status' => 'success', 'title' => __('Success!', 'wp-delete-user-accounts'), 'message' => __('Your account was successfully deleted. Fair well.', 'wp-delete-user-accounts')));
} else {
wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Request failed.', 'wp-delete-user-accounts')));
}
}
示例4: display
public function display()
{
if (isset($_GET['form_id'])) {
if ('new' == $_GET['form_id']) {
$form_id = 'tmp-' . time();
} else {
$form_id = is_numeric($_GET['form_id']) ? absint($_GET['form_id']) : '';
}
/*
* FORM BUILDER
*/
Ninja_Forms::template('admin-menu-new-form.html.php');
$this->_enqueue_the_things($form_id);
delete_user_option(get_current_user_id(), 'nf_form_preview_' . $form_id);
if (!isset($_GET['ajax'])) {
$this->_localize_form_data($form_id);
$this->_localize_field_type_data();
$this->_localize_action_type_data();
$this->_localize_form_settings();
$this->_localize_merge_tags();
}
} else {
/*
* ALL FORMS TABLE
*/
$this->table->prepare_items();
Ninja_Forms::template('admin-menu-all-forms.html.php', array('table' => $this->table, 'add_new_url' => admin_url('admin.php?page=ninja-forms&form_id=new'), 'add_new_text' => __('Add New Form', 'ninja-forms')));
}
}
示例5: archive
public function archive($bolo_id)
{
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "bolo_creator";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//mark bolo as archived
$sql2 = <<<SQL
\t UPDATE wp_flierform
\t SET archive = TRUE
\t WHERE bolo_id = "{$boloid}"
SQL;
if (!($result = $conn->query($sql2))) {
die('There was an error running the query [' . $db->error . ']');
}
//archive the bolo
$author = get_current_user_id();
$sql = <<<SQL
\t INSERT INTO bolo_archive
\t SELECT *, "{$author}" AS archive_author, CURRENT_TIMESTAMP()
\t FROM wp_flierform\t
\t WHERE bolo_id = "{$boloid}"
SQL;
if (!($result = $conn->query($sql))) {
die('There was an error running the query [' . $db->error . ']');
}
}
示例6: add_pointers
public function add_pointers()
{
$pointers = $this->pointers;
if (!$pointers || !is_array($pointers)) {
return;
}
// Get dismissed pointers
$dismissed = explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true));
$valid_pointers = array();
// Check pointers and remove dismissed ones.
foreach ($pointers as $pointer_id => $pointer) {
// Make sure we have pointers & check if they have been dismissed
if (in_array($pointer_id, $dismissed) || empty($pointer) || empty($pointer_id) || empty($pointer['target']) || empty($pointer['options'])) {
continue;
}
$pointer['pointer_id'] = $pointer_id;
// Add the pointer to $valid_pointers array
$valid_pointers['pointers'][] = $pointer;
}
// No valid pointers? Stop here.
if (empty($valid_pointers)) {
return;
}
$this->valid = $valid_pointers;
wp_enqueue_style('wp-pointer');
wp_enqueue_script('wp-pointer');
}
示例7: show_seller_enable_message
/**
* Show Seller Enable Error Message
*
* @since 2.4
*
* @return void
*/
public function show_seller_enable_message()
{
$user_id = get_current_user_id();
if (!dokan_is_seller_enabled($user_id)) {
echo dokan_seller_not_enabled_notice();
}
}
示例8: user_role_change
/**
* Synchronize connected user role changes
*/
static function user_role_change($user_id)
{
if (Jetpack::is_active() && Jetpack::is_user_connected($user_id)) {
$current_user_id = get_current_user_id();
wp_set_current_user($user_id);
$role = Jetpack::translate_current_user_to_role();
$signed_role = Jetpack::sign_role($role);
wp_set_current_user($current_user_id);
$master_token = Jetpack_Data::get_access_token(JETPACK_MASTER_USER);
$master_user_id = absint($master_token->external_user_id);
if (!$master_user_id) {
return;
}
// this shouldn't happen
Jetpack::xmlrpc_async_call('jetpack.updateRole', $user_id, $signed_role);
//@todo retry on failure
//try to choose a new master if we're demoting the current one
if ($user_id == $master_user_id && 'administrator' != $role) {
$query = new WP_User_Query(array('fields' => array('id'), 'role' => 'administrator', 'orderby' => 'id', 'exclude' => array($master_user_id)));
$new_master = false;
foreach ($query->results as $result) {
$uid = absint($result->id);
if ($uid && Jetpack::is_user_connected($uid)) {
$new_master = $uid;
break;
}
}
if ($new_master) {
Jetpack_Options::update_option('master_user', $new_master);
}
// else disconnect..?
}
}
}
示例9: _admin_init
function _admin_init()
{
global $post;
$screen = get_current_screen();
$pointers = array();
if ($screen->base == 'post' && $screen->post_type == UBERGRID_POST_TYPE) {
$pointers = array('#add-new-cell' => array('title' => __('Add a cell', 'uber-grid'), 'content' => __('<p>Click here to add a first cell to your grid.</p>', 'uber-grid'), 'position' => array('edge' => 'right', 'align' => 'center')), '#shortcode' => array('title' => __('Save your grid', 'uber-grid'), 'content' => sprintf(__('<p>After saving your grid, insert this code <strong>[ubergrid id=%s]</strong> into your site pages to use the grid.</p>', 'uber-grid'), $post->ID), 'position' => array('edge' => 'top')));
}
if ($screen->base == 'edit' && $screen->post_type == UBERGRID_POST_TYPE) {
$pointers = array('.add-new-h2' => array('title' => __('Create a grid', 'uber-grid'), 'content' => __('<p>Please click here to create your first grid.</p>', 'uber-grid')));
}
$disabled = get_user_meta(get_current_user_id(), 'uber_grid_disabled_pointers', true);
if ($disabled) {
foreach ($disabled as $item) {
if (isset($pointers[$item])) {
unset($pointers[$item]);
}
}
}
if ($pointers) {
wp_enqueue_script("wp-pointer");
wp_enqueue_style("wp-pointer");
wp_enqueue_script('uber-grid-pointers', UBERGRID_URL . 'assets/js/admin-pointers.js');
wp_localize_script('uber-grid-pointers', 'uber_grid_pointers', array($pointers));
}
}
示例10: test_hide_all_for_user
/**
* @group get
*/
public function test_hide_all_for_user()
{
$activity = $this->factory->activity->create(array('type' => 'activity_update'));
BP_Activity_Activity::hide_all_for_user(get_current_user_id());
$activity = BP_Activity_Activity::get(array('in' => $activity, 'show_hidden' => true));
$this->assertEquals($activity['activities'][0]->hide_sitewide, 1);
}
示例11: add_save
public function add_save()
{
$rules = array(array('field' => 'name', 'label' => 'name', 'rules' => 'trim|required'), array('field' => 'address', 'label' => 'address', 'rules' => 'trim|required'), array('field' => 'contact_person', 'label' => 'contact person', 'rules' => 'trim|required'), array('field' => 'phone', 'label' => 'phone', 'rules' => 'trim'), array('field' => 'fax', 'label' => 'fax', 'rules' => 'trim'), array('field' => 'email', 'label' => 'email', 'rules' => 'trim|valid_email'), array('field' => 'qq', 'label' => 'QQ', 'rules' => 'trim'), array('field' => 'username', 'label' => 'user name', 'rules' => 'trim'), array('field' => 'web', 'label' => 'web', 'rules' => 'trim'));
$this->form_validation->set_rules($rules);
if ($this->form_validation->run() == FALSE) {
$error = validation_errors();
echo $this->create_json(0, $error);
return;
}
// check if the provider exists ?
if ($this->purchase_model->check_exists('purchase_provider', array('name' => $this->input->post('name')))) {
echo $this->create_json(0, lang('provider_exists'));
return;
}
$edit_user = get_current_user_id();
$data = array('name' => trim($this->input->post('name')), 'boss' => trim($this->input->post('boss')), 'address' => trim($this->input->post('address')), 'phone' => trim($this->input->post('phone')), 'fax' => trim($this->input->post('fax')), 'email' => trim($this->input->post('email')), 'qq' => trim($this->input->post('qq')), 'web' => trim($this->input->post('web')), 'contact_person' => trim($this->input->post('contact_person')), 'mobile' => trim($this->input->post('mobile')), 'open_bank' => trim($this->input->post('open_bank')), 'bank_account' => trim($this->input->post('bank_account')), 'bank_title' => trim($this->input->post('bank_title')), 'edit_user' => $edit_user, 'remark' => trim($this->input->post('remark')));
try {
$provider_id = $this->purchase_model->add_a_new_provider($data);
$user_ids = $this->input->post('permissions');
if (!is_array($user_ids)) {
settype($user_ids, 'array');
}
$user_id = $this->get_current_user_id();
if (in_array($user_id, $user_ids) == FALSE) {
array_push($user_ids, $user_id);
}
$this->purchase_model->save_purchase_permissions($provider_id, $user_ids);
echo $this->create_json(1, lang('provider_saved'));
} catch (Exception $e) {
echo lang('error_msg');
$this->ajax_failed();
}
}
示例12: send_page_data_to_template
/**
* load data needed for board's javascript
* @param string $template the passed in template path
* @return string the same template path
*/
static function send_page_data_to_template($template)
{
if (!isset(Kanban_Template::get_instance()->slug) || Kanban_Template::get_instance()->slug != self::$slug) {
return $template;
}
global $wp_query;
$wp_query->query_vars['kanban'] = (object) array();
$wp_query->query_vars['kanban']->board = (object) array();
// // get all data for the javascript
$wp_query->query_vars['kanban']->board->allowed_users = Kanban_User::get_allowed_users();
$wp_query->query_vars['kanban']->board->estimates = Kanban_Terms::terms_in_order('task', 'estimate');
$wp_query->query_vars['kanban']->board->status_tax_key = Kanban_Utils::format_key('task', 'status');
$wp_query->query_vars['kanban']->board->status_color_field_name = sprintf('%s_colors', $wp_query->query_vars['kanban']->board->status_tax_key);
$wp_query->query_vars['kanban']->board->status_colors = Kanban_Settings::get_option($wp_query->query_vars['kanban']->board->status_color_field_name, null, array());
$wp_query->query_vars['kanban']->board->statuses = Kanban_Terms::terms_in_order('task', 'status');
foreach ($wp_query->query_vars['kanban']->board->statuses as $status) {
if (!isset($wp_query->query_vars['kanban']->board->status_colors[$status->term_id])) {
continue;
}
$status->color = $wp_query->query_vars['kanban']->board->status_colors[$status->term_id];
}
$wp_query->query_vars['kanban']->board->projects = Kanban_Project::get_all();
$wp_query->query_vars['kanban']->board->tasks = Kanban_Task::get_all();
$current_user_id = get_current_user_id();
$wp_query->query_vars['kanban']->board->current_user = get_user_by('id', $current_user_id);
unset($wp_query->query_vars['kanban']->board->current_user->data->user_pass);
$wp_query->query_vars['kanban']->board->current_user->data->long_name_email = Kanban_User::format_user_name($wp_query->query_vars['kanban']->board->current_user);
$wp_query->query_vars['kanban']->board->current_user->data->short_name = Kanban_User::format_user_name($wp_query->query_vars['kanban']->board->current_user, TRUE);
$wp_query->query_vars['kanban']->board->current_user->data->initials = Kanban_User::get_initials($wp_query->query_vars['kanban']->board->current_user);
$wp_query->query_vars['kanban']->board->col_percent_w = count($wp_query->query_vars['kanban']->board->statuses) > 0 ? 100 / count($wp_query->query_vars['kanban']->board->statuses) : 100;
$wp_query->query_vars['kanban']->board->sidebar_w = count($wp_query->query_vars['kanban']->board->statuses) > 0 ? 100 / (count($wp_query->query_vars['kanban']->board->statuses) - 2) : 0;
return $template;
}
示例13: display_payment_gateway_settings_form
public function display_payment_gateway_settings_form()
{
$selected_gateway = (string) get_user_option('wpsc_settings_selected_payment_gateway', get_current_user_id());
if (empty($selected_gateway) && !empty($this->active_gateways)) {
$selected_gateway = $this->active_gateways[0];
}
$payment_data = $this->get_gateway_form($selected_gateway);
if (!$payment_data) {
$payment_data = array('name' => __('Edit Gateway Settings', 'wpsc'), 'form_fields' => __('Modify a payment gateway settings by clicking "Edit" link on the left.', 'wpsc'));
}
?>
<td id='wpsc-payment-gateway-settings-panel' class='wpsc-module-settings' rowspan='2'>
<div class='postbox'>
<h3 class='hndle'><?php
echo $payment_data['name'];
?>
</h3>
<div class='inside'>
<table class='form-table'>
<?php
echo $payment_data['form_fields'];
?>
</table>
<div class='submit'>
<input type='submit' value='<?php
_e('Update »', 'wpsc');
?>
' />
</div>
</div>
</td>
<?php
}
示例14: vote_poll
/**
* Poll Voting
* @since 1.1
* @version 1.1
*/
public function vote_poll()
{
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'polls' && is_user_logged_in()) {
// Get Poll ID
$poll_id = isset($_REQUEST['poll_id']) ? intval($_REQUEST['poll_id']) : 0;
// Ensure Poll ID Is Valid
if ($poll_id != 0) {
// Verify Referer
if (check_ajax_referer('poll_' . $poll_id . '-nonce', 'poll_' . $poll_id . '_nonce', false)) {
// Which View
switch ($_REQUEST['view']) {
case 'process':
$poll_aid = $_POST["poll_{$poll_id}"];
$poll_aid_array = array_unique(array_map('intval', explode(',', $poll_aid)));
if ($poll_id > 0 && !empty($poll_aid_array) && check_allowtovote()) {
$check_voted = check_voted($poll_id);
if ($check_voted == 0) {
$user_id = get_current_user_id();
// Make sure we are not excluded
if (!$this->core->exclude_user($user_id)) {
$this->core->add_creds('poll_voting', $user_id, $this->prefs['creds'], $this->prefs['log'], $poll_id, array('ref_type' => 'poll'), $this->mycred_type);
}
}
}
break;
}
}
}
}
}
示例15: saveFieldset
/**
* Uloží fieldset
* VOLÁ SE V HOOCE
*
* @author Jan Pokorný
* @param int $user_id
*/
public function saveFieldset($user_id)
{
if (get_current_user_id() != $user_id && !current_user_can('edit_users')) {
return;
}
$fieldset = $this->getFieldset();
$form = new KT_form();
$form->addFieldSetByObject($fieldset);
$form->validate();
if ($form->hasError()) {
// TODO has error
}
if ($fieldset->getSerializeSave()) {
$fieldsetData = $form->getSavableFieldsetGroupValue($fieldset);
if (KT::arrayIssetAndNotEmpty($fieldsetData)) {
update_user_meta($user_id, $fieldset->getName(), $fieldsetData);
} else {
delete_user_meta($user_id, $fieldset->getName());
}
} else {
foreach ($fieldset->getFields() as $field) {
$fieldValue = $form->getSavableFieldValue($field);
if ($field && $fieldValue !== "") {
update_user_meta($user_id, $field->getName(), $fieldValue);
} else {
delete_user_meta($user_id, $field->getName());
}
}
}
}