本文整理汇总了PHP中user_can函数的典型用法代码示例。如果您正苦于以下问题:PHP user_can函数的具体用法?PHP user_can怎么用?PHP user_can使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_can函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: verify_cookie
public static function verify_cookie($value)
{
if ($old_user_id = wp_validate_auth_cookie($value, 'logged_in')) {
return user_can($old_user_id, 'view_query_monitor');
}
return false;
}
开发者ID:giridhar9,项目名称:Portfolio,代码行数:7,代码来源:Dispatcher.php
示例2: pg_get_user_replies_created
function pg_get_user_replies_created($user_id = 0)
{
// Validate user
$user_id2 = bbp_get_user_id($user_id);
$current_user = wp_get_current_user()->ID;
if (empty($user_id)) {
return false;
}
if (bbp_is_user_keymaster()) {
$limit = 'n';
}
if (user_can($current_user, 'moderate')) {
$check = get_user_meta($current_user, 'private_group', true);
if ($check == '') {
$limit = 'n';
}
}
if ($limit != 'n') {
global $wpdb;
$reply = bbp_get_reply_post_type();
$post_ids = $wpdb->get_col("select ID from {$wpdb->posts} where post_type = '{$reply}'");
//check this list against those the user is allowed to see, and create a list of valid ones for the wp_query in bbp_has_topics
$allowed_posts = check_private_groups_reply_ids($post_ids);
}
// The default reply query with allowed topic and reply ids array added
// Try to get the topics
$query = bbp_has_replies(array('post_type' => bbp_get_reply_post_type(), 'order' => 'DESC', 'author' => $user_id2, 'post__in' => $allowed_posts));
return apply_filters('pg_get_user_replies_created', $query, $user_id);
}
开发者ID:USSLomaPrieta,项目名称:usslomaprieta.org,代码行数:29,代码来源:replies.php
示例3: save
public function save($id = null)
{
$this->load->helper('memberspace/authorization');
$this->load->helper('flashmessages/flashmessages');
$this->load->model('memberspace/user');
$this->load->helper('form');
$datas = array();
if (isset($_POST) && isset($_POST['save-user'])) {
$datas = $_POST;
unset($_POST['save-user']);
if (isset($_POST['id']) && $_POST['id']) {
if (!user_can('update', 'user', $_POST['id'])) {
add_error(translate('Vous ne pouvez pas modifier cet utilisateur'));
}
} else {
if (!user_can('add', 'user', $_POST['id'])) {
add_error(translate('Vous ne pouvez pas ajouter d\'utilisateur'));
}
}
if ($this->user->fromPost() !== false) {
add_success(translate('L\'utilisateur a bien été ajouté'));
redirect('bo/users/all');
} else {
add_error($this->form_validation->error_string());
}
} else {
if ($id) {
$datas = $this->user->getId($id, 'array');
}
}
return $datas;
}
开发者ID:Cevantime,项目名称:site-core-modules,代码行数:32,代码来源:Users.php
示例4: dwqa_single_postclass
function dwqa_single_postclass($post_class)
{
global $post, $current_user;
if (get_post_type($post) == 'dwqa-answer') {
$post_class[] = 'dwqa-answer';
$post_class[] = 'dwqa-status-' . get_post_status($post->ID);
if (dwqa_is_answer_flag($post->ID)) {
$post_class[] = 'answer-flagged-content';
}
if (user_can($post->post_author, 'edit_published_posts')) {
$post_class[] = 'staff';
}
$question_id = get_post_meta($post->ID, '_question', true);
$best_answer_id = dwqa_get_the_best_answer($question_id);
if ($best_answer_id && $best_answer_id == $post->ID) {
$post_class[] = 'best-answer';
}
if (!is_user_logged_in() || $current_user->ID != $post->ID || !current_user_can('edit_posts')) {
$post_class[] = 'dwqa-no-click';
}
}
if (get_post_type($post) == 'dwqa-answer' && get_post_type($post) == 'dwqa-question') {
if (in_array('hentry', $post_class)) {
unset($post_class);
}
}
return $post_class;
}
开发者ID:anupomdebnath,项目名称:dw-question-answer,代码行数:28,代码来源:template-functions.php
示例5: check_follow
function check_follow($matches)
{
#support of "meta=follow" option for admins. disabled by default to minify processing.
if (!$this->options['dont_mask_admin_follow']) {
return false;
}
$id = array(get_comment_ID(), get_the_ID());
//it is either page or post
if ($id[0]) {
$this->debug_info('It is a comment. id ' . $id[0]);
} elseif ($id[1]) {
$this->debug_info('It is a page. id ' . $id[1]);
}
$author = false;
if ($id[0]) {
$author = get_comment_author($id[0]);
} else {
if ($id[1]) {
$author = get_the_author_meta('ID');
}
}
if (!$author) {
$this->debug_info('it is neither post or page, applying usual rules');
} elseif (user_can($author, 'manage_options') && (stripos($matches[0], 'rel="follow"') !== FALSE || stripos($matches[0], "rel='follow'") !== FALSE)) {
$this->debug_info('This link has a follow atribute and is posted by admin, not masking it.');
#wordpress adds rel="nofollow" by itself when posting new link in comments. get rid of it! Also, remove our follow attibute - it is unneccesary.
return str_ireplace(array('rel="follow"', "rel='follow'", 'rel="nofollow"'), '', $matches[0]);
} else {
$this->debug_info('it does not have rel follow or is not posted by admin, masking it');
}
return false;
}
开发者ID:Hevix,项目名称:hevix,代码行数:32,代码来源:wp-noexternallinks-parser.php
示例6: user_can_translate
/**
* Checks whether the input user is allowed to edit this job
*
* @param stdClass|WP_User $user
*
* @return bool
*/
public function user_can_translate($user)
{
$translator_id = $this->get_translator_id();
$user_can_take_this_job = $translator_id === 0 || $translator_id === (int) $user->ID;
$translator_has_job_language_pairs = $this->blog_translators->is_translator($user->ID, array('lang_from' => $this->get_source_language_code(), 'lang_to' => $this->get_language_code()));
return $user_can_take_this_job && $translator_has_job_language_pairs || method_exists($user, 'has_cap') && $user->has_cap('manage_options') || !method_exists($user, 'has_cap') && user_can($user->ID, 'manage_options');
}
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:14,代码来源:wpml-translation-job.class.php
示例7: fes_22_upgrade_vendor_permissions
/**
* Upgrades vendor permissions
*
* @since 2.2
* @return void
*/
function fes_22_upgrade_vendor_permissions()
{
$fes_version = get_option('fes_db_version', '2.1');
if (version_compare($fes_version, '2.2', '>=')) {
return;
}
ignore_user_abort(true);
if (!edd_is_func_disabled('set_time_limit') && !ini_get('safe_mode')) {
set_time_limit(0);
}
$step = isset($_GET['step']) ? absint($_GET['step']) : 1;
$offset = $step == 1 ? 0 : $step * 100;
$users = new WP_User_Query(array('fields' => 'ID', 'number' => 100, 'offset' => $offset));
$users = $users->results;
if ($users && count($users) > 0) {
foreach ($users as $user => $id) {
if (user_can($id, 'fes_is_vendor') && !user_can($id, 'fes_is_admin') && !user_can($id, 'administrator') && !user_can($id, 'editor')) {
$user = new WP_User($id);
$user->add_role('frontend_vendor');
}
}
// Keys found so upgrade them
$step++;
$redirect = add_query_arg(array('page' => 'fes-upgrades', 'edd_upgrade' => 'upgrade_vendor_permissions', 'step' => $step), admin_url('index.php'));
wp_redirect($redirect);
exit;
} else {
// No more keys found, update the DB version and finish up
update_option('fes_db_version', fes_plugin_version);
wp_redirect(admin_url('admin.php?page=fes-about'));
exit;
}
}
开发者ID:SelaInc,项目名称:eassignment,代码行数:39,代码来源:class-update.php
示例8: testTranslatorCaps
function testTranslatorCaps()
{
global $wp_roles;
$this->assertTrue($wp_roles->is_role('translator'));
# Translators can manage translation jobs:
$this->assertTrue(user_can($this->translator->ID, 'edit_bbl_jobs'));
}
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:7,代码来源:test-roles.php
示例9: force_2fa
function force_2fa()
{
// Allows WP.com login to a local account if it matches the local account.
add_filter('jetpack_sso_match_by_email', '__return_true', 9999);
// multisite
if (is_multisite()) {
// Hide the login form
add_filter('jetpack_remove_login_form', '__return_true', 9999);
add_filter('jetpack_sso_bypass_login_forward_wpcom', '__return_true', 9999);
add_filter('jetpack_sso_display_disclaimer', '__return_false', 9999);
add_filter('wp_authenticate_user', function () {
return new WP_Error('wpcom-required', "Local login disabled for this site.");
}, 9999);
add_filter('jetpack_sso_require_two_step', '__return_true');
add_filter('allow_password_reset', '__return_false');
} else {
// Completely disable the standard login form for admins.
add_filter('wp_authenticate_user', function ($user) {
if ($user->has_cap($this->role)) {
return new WP_Error('wpcom-required', "Local login disabled for this account.", $user->user_login);
}
return $user;
}, 9999);
add_filter('allow_password_reset', function ($allow, $user_id) {
if (user_can($user_id, $this->role)) {
return false;
}
return $allow;
}, 9999, 2);
add_action('jetpack_sso_pre_handle_login', array($this, 'jetpack_set_two_step_for_admins'));
}
}
开发者ID:Automattic,项目名称:jetpack-force-2fa,代码行数:32,代码来源:jetpack-force-2fa.php
示例10: bogo_get_user_locale
function bogo_get_user_locale($user_id = 0)
{
global $current_user;
$default_locale = bogo_get_default_locale();
$user_id = absint($user_id);
if (!$user_id) {
if (function_exists('wp_get_current_user') && !empty($current_user)) {
$user_id = get_current_user_id();
} elseif (!($user_id = apply_filters('determine_current_user', false))) {
return $default_locale;
}
}
$locale = get_user_option('locale', $user_id);
if (bogo_is_available_locale($locale) && user_can($user_id, 'bogo_access_locale', $locale)) {
return $locale;
}
if (user_can($user_id, 'bogo_access_locale', $default_locale)) {
return $default_locale;
}
foreach ((array) bogo_available_locales() as $locale) {
if (user_can($user_id, 'bogo_access_locale', $locale)) {
return $locale;
}
}
return $default_locale;
}
开发者ID:karthikakamalanathan,项目名称:wp-cookieLawInfo,代码行数:26,代码来源:user.php
示例11: pg_has_topics
function pg_has_topics($args = '')
{
//check if being called by subscriptions and if so skip filtering (as you can only subscribe to forums you can already see)
if ($args['post__in']) {
return $args;
}
$default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
if ($default_post_parent == 'any') {
if (bbp_is_user_keymaster()) {
return $args;
}
$user_id = wp_get_current_user()->ID;
if (user_can($user_id, 'moderate')) {
$check = get_user_meta($user_id, 'private_group', true);
if ($check == '') {
return $args;
}
}
global $wpdb;
$topic = bbp_get_topic_post_type();
$post_ids = $wpdb->get_col("select ID from {$wpdb->posts} where post_type = '{$topic}'");
//check this list against those the user is allowed to see, and create a list of valid ones for the wp_query in bbp_has_topics
$allowed_posts = check_private_groups_topic_ids($post_ids);
$args['post__in'] = $allowed_posts;
}
return $args;
}
开发者ID:USSLomaPrieta,项目名称:usslomaprieta.org,代码行数:27,代码来源:topics.php
示例12: save
public function save($userModel = 'memberspace/user', $mailRedirect = 'memberspace/confirmation/confirm', $redirect = null)
{
$post = $this->input->post();
$modelName = pathinfo($userModel)['filename'];
if (!$post || !isset($post['save-' . $modelName])) {
return array();
}
unset($_POST['save-' . $modelName]);
$this->load->library('form_validation');
if (isset($post['id']) && !user_can('update', $userModel, $post['id'])) {
return $post;
}
$this->load->model($userModel);
$userId = $this->{$modelName}->fromPost();
if ($userId === false) {
add_error($this->form_validation->error_string());
return $post;
}
if (!isset($post['id'])) {
$this->sendMailConfirmation($userId, $mailRedirect);
add_success('Vous avez bien été inscrit !');
} else {
add_success('Vous avez bien mis à jour vos informations');
}
if ($redirect) {
redirect($redirect);
}
return $post;
}
开发者ID:Cevantime,项目名称:site-core-modules,代码行数:29,代码来源:Register.php
示例13: schoolpress_admin_check
function schoolpress_admin_check()
{
global $user_ID;
if (!user_can($user_ID, 'administrator')) {
wp_redirect(site_url());
}
}
开发者ID:Cywaithaka,项目名称:bwawwp,代码行数:7,代码来源:example-7.php
示例14: jr_process_login_form
function jr_process_login_form()
{
global $posted;
if (isset($_REQUEST['redirect_to'])) {
$redirect_to = $_REQUEST['redirect_to'];
} else {
$redirect_to = admin_url();
}
if (is_ssl() && force_ssl_login() && !force_ssl_admin() && 0 !== strpos($redirect_to, 'https') && 0 === strpos($redirect_to, 'http')) {
$secure_cookie = false;
} else {
$secure_cookie = '';
}
$user = wp_signon('', $secure_cookie);
$redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
if (!is_wp_error($user)) {
if (user_can($user, 'manage_options')) {
$redirect_to = admin_url();
}
wp_safe_redirect($redirect_to);
exit;
}
$errors = $user;
return $errors;
}
开发者ID:besimhu,项目名称:legacy,代码行数:25,代码来源:login-process.php
示例15: _save_search
private static function _save_search($args)
{
extract($args);
if (!empty($user) && !empty($hash)) {
if (!user_can($user->ID, self::$_capabilities['save_search']) || user_can($user->ID, self::$_capabilities['view_leads'])) {
return 'User does not have the capability to save searches.';
}
if (empty($name_exists)) {
$saved_searches = !empty($user->{self::$_meta_keys['lead']['saved_searches']}) ? $user->{self::$_meta_keys['lead']['saved_searches']} : array();
$this_search = array('hash' => $hash, 'name' => $search_name);
if (!empty($user->{self::$_meta_keys['api_user_id']})) {
$saved_search_criteria = DispletRetsIdxResidentialsModel::get_search_criteria_from_hash($hash);
$saved_search_id = DispletRetsIdxUsersApiController::create_saved_search($user->{self::$_meta_keys['api_user_id']}, $search_name, $saved_search_criteria);
if (isset($saved_search_id)) {
$this_search['api_id'] = $saved_search_id;
}
}
$saved_searches[] = $this_search;
update_user_meta($user->ID, self::$_meta_keys['lead']['saved_searches'], $saved_searches);
new DispletRetsIdxEmail('saved_search', array('agent_id' => DispletRetsIdxLeadsModel::get_assigned_agent_id($user->ID), 'lender_id' => DispletRetsIdxLeadsModel::get_assigned_lender_id($user->ID), 'search_url' => trailingslashit(get_permalink(self::$_options['search_results_page_id'])) . $hash, 'user_email' => $user->user_email, 'user_name' => $user->display_name, 'user_phone' => $user->{self::$_meta_keys['lead']['phone']}));
do_action('displetretsidx_post_lead_saved_search', $user->ID, $this_search);
return 'Saved Search';
}
}
}
开发者ID:amankatoch,项目名称:wp-plugin,代码行数:25,代码来源:class-displet-rets-idx-saved-searches-controller.php
示例16: ajax_return_to_admin_panel
function ajax_return_to_admin_panel()
{
global $wpdb;
if (!empty($_POST['secure_key'])) {
$verify = $_POST['secure_key'];
} else {
exit(json_encode(array('status' => false, 'message' => __("Wrong data", WPC_CLIENT_TEXT_DOMAIN))));
}
if (!empty($_COOKIE['wpc_key']) && is_user_logged_in()) {
$key = $_COOKIE['wpc_key'];
$user_data = $wpdb->get_row($wpdb->prepare("SELECT umeta_id, user_id, meta_value FROM {$wpdb->usermeta} WHERE meta_key = 'wpc_client_admin_secure_data' AND meta_value LIKE '%s'", '%"' . md5($key) . '"%'), ARRAY_A);
if (isset($user_data['user_id']) && user_can($user_data['user_id'], 'wpc_admin_user_login') && wp_verify_nonce($verify, get_current_user_id() . $user_data['user_id'])) {
if (!empty($user_data['meta_value'])) {
$secure_array = unserialize($user_data['meta_value']);
if (isset($secure_array['end_date']) && $secure_array['end_date'] > time()) {
wp_set_auth_cookie($user_data['user_id'], true);
$wpdb->delete($wpdb->usermeta, array('umeta_id' => $user_data['umeta_id']));
$secure_logged_in_cookie = 'https' === parse_url(get_option('home'), PHP_URL_SCHEME);
setcookie("wpc_key", '', time() - 1, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
exit(json_encode(array('status' => true, 'message' => admin_url('admin.php?page=wpclient_clients'))));
}
}
}
}
exit(json_encode(array('status' => false, 'message' => __("Wrong data", WPC_CLIENT_TEXT_DOMAIN))));
}
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:26,代码来源:class.ajax.php
示例17: govi_main_theme_menu
function govi_main_theme_menu()
{
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
if (!user_can($user_id, 'create_users')) {
return false;
}
?>
<div class="wrap govi-panel-wrap">
<div class="govi-admin-title-wrap"><h2>PMC Opções do Tema</h2></div>
<div class="settings-top-strip"><a id="general-button" class="general-save-button" href="#">Salvar Opções</a></div>
<div id="tabs">
<ul>
<li><a rel="govi-generla-settings" href="#govi-general-settings">Opções Gerais</a></li>
<li><a rel="govi-homepage-settings" href="#govi-home-settings">Página de Inicio</a></li>
<li><a rel="govi-contact-links" href="#govi-contact-links">Links de Contato</a></li>
<li><a rel="govi-element-settings" href="#govi-element-setings">Elementos</a></li>
<li><a rel="govi-color-picker-elements-tab" href="#govi-social-midia">Redes Sociais</a></li>
</ul>
<?php
general_settings();
govi_home_settings();
govi_contact_links();
govi_element_settings();
govi_social_midia_links();
?>
</div>
<div class="settings-bottom-strip"><a id="general-button" class="general-save-button" href="#">Salvar Opções</a></div>
</div>
<?php
}
开发者ID:govijuan,项目名称:pacto-mundial-conciente-br,代码行数:33,代码来源:govi-admin.php
示例18: test_filter_user_has_cap
/**
* Test filtering user_has_cap.
*
* @see Plugin::filter_user_has_cap()
*/
function test_filter_user_has_cap()
{
$admin_user_id = $this->factory->user->create(array('role' => 'administrator'));
$editor_user_id = $this->factory->user->create(array('role' => 'editor'));
$this->assertFalse(user_can($editor_user_id, 'customize_publish'));
$this->assertTrue(user_can($admin_user_id, 'customize_publish'));
}
开发者ID:xwp,项目名称:wp-customize-snapshots,代码行数:12,代码来源:test-class-plugin.php
示例19: beans_comment_badges
/**
* Echo the comment badges.
*
* @since 1.0.0
*/
function beans_comment_badges()
{
global $comment;
// Trackback badge.
if ($comment->comment_type == 'trackback') {
echo beans_open_markup('beans_trackback_badge', 'span', array('class' => 'uk-badge uk-margin-small-left'));
echo beans_output('beans_trackback_text', __('Trackback', 'tm-beans'));
echo beans_close_markup('beans_trackback_badge', 'span');
}
// Pindback badge.
if ($comment->comment_type == 'pingback') {
echo beans_open_markup('beans_pingback_badge', 'span', array('class' => 'uk-badge uk-margin-small-left'));
echo beans_output('beans_pingback_text', __('Pingback', 'tm-beans'));
echo beans_close_markup('beans_pingback_badge', 'span');
}
// Moderation badge.
if ('0' == $comment->comment_approved) {
echo beans_open_markup('beans_moderation_badge', 'span', array('class' => 'uk-badge uk-margin-small-left uk-badge-warning'));
echo beans_output('beans_moderation_text', __('Awaiting Moderation', 'tm-beans'));
echo beans_close_markup('beans_moderation_badge', 'span');
}
// Moderator badge.
if (user_can($comment->user_id, 'moderate_comments')) {
echo beans_open_markup('beans_moderator_badge', 'span', array('class' => 'uk-badge uk-margin-small-left'));
echo beans_output('beans_moderator_text', __('Moderator', 'tm-beans'));
echo beans_close_markup('beans_moderator_badge', 'span');
}
}
开发者ID:MatRouault,项目名称:Beans,代码行数:33,代码来源:comments.php
示例20: render
/**
* Render the user meta box in WordPress, associating it to the specified
* user roles.
*
* @since 0.2.0
*/
public function render()
{
global $user_id;
if ($user_id) {
$user = get_user_by('id', $user_id);
if (!$user) {
return;
}
/* Check if the meta box should be displayed for the current user's role. */
$check_current_user_role = true;
if (!empty($this->_roles)) {
foreach ((array) $this->_roles as $role) {
$check_current_user_role = user_can($user, $role);
if ($check_current_user_role) {
break;
}
}
}
if (!$check_current_user_role) {
return;
}
/* Check if the current can edit the user. */
$check_current_user_can_edit_user = $user && current_user_can('edit_user', $user->ID);
if (!$check_current_user_can_edit_user) {
return;
}
echo '<div class="ev ev-native-meta ev-user-metabox">';
wp_nonce_field('ev_user_meta_box', 'ev');
printf('<h3>%s</h3>', esc_html($this->title()));
$this->render_elements();
echo '</div>';
}
}
开发者ID:Justevolve,项目名称:evolve-framework,代码行数:39,代码来源:ev_user_meta_box.php
注:本文中的user_can函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论