• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP um_user_can函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了um_user_can函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: um_remove_special_users_from_list

function um_remove_special_users_from_list($query_args, $args)
{
    global $ultimatemember;
    extract($args);
    if (!um_user_can('can_edit_everyone')) {
        $query_args['meta_query'][] = array('key' => 'account_status', 'value' => 'approved', 'compare' => '=');
    }
    $query_args['meta_query'][] = array('key' => 'hide_in_members', 'value' => '', 'compare' => 'NOT EXISTS');
    return $query_args;
}
开发者ID:smithsa,项目名称:daily-job-hunter,代码行数:10,代码来源:um-filters-members.php


示例2: new_user_upload

 function new_user_upload($user_id, $source, $key)
 {
     // if he does not have uploads dir yet
     $this->new_user($user_id);
     if (is_user_logged_in() && get_current_user_id() != $user_id && !um_user_can('can_edit_everyone')) {
         wp_die(__('Unauthorized to do this attempt.', 'ultimatemember'));
     }
     if (!is_user_logged_in() && ($key == 'profile_photo' || $key == 'cover_photo')) {
         wp_die(__('Unauthorized to do this attempt.', 'ultimatemember'));
     }
     // name and extension stuff
     $source_name = basename($source);
     if ($key == 'profile_photo') {
         $source_name = 'profile_photo.jpg';
     }
     if ($key == 'cover_photo') {
         $source_name = 'cover_photo.jpg';
     }
     $ext = '.' . pathinfo($source_name, PATHINFO_EXTENSION);
     $name = str_replace($ext, '', $source_name);
     $filename = $name . $ext;
     // copy & overwrite file
     if (file_exists($this->upload_basedir . $user_id . '/' . $filename)) {
         unlink($this->upload_basedir . $user_id . '/' . $filename);
     }
     copy($source, $this->upload_basedir . $user_id . '/' . $filename);
     // thumbs
     if ($key == 'profile_photo') {
         list($w, $h) = @getimagesize($source);
         $sizes = um_get_option('photo_thumb_sizes');
         foreach ($sizes as $size) {
             if (file_exists($this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext)) {
                 unlink($this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext);
             }
             if ($size < $w) {
                 $thumb_s = imagecreatefromjpeg($source);
                 $thumb = imagecreatetruecolor($size, $size);
                 imagecopyresampled($thumb, $thumb_s, 0, 0, 0, 0, $size, $size, $w, $h);
                 imagejpeg($thumb, $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext, 100);
             }
         }
         // removes a synced profile photo
         delete_user_meta($user_id, 'synced_profile_photo');
     }
     if ($key == 'cover_photo') {
         list($w, $h) = @getimagesize($source);
         $sizes = um_get_option('cover_thumb_sizes');
         foreach ($sizes as $size) {
             $ratio = round($w / $h, 2);
             $height = round($size / $ratio, 2);
             if (file_exists($this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext)) {
                 unlink($this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext);
             }
             if ($size < $w) {
                 $thumb_s = imagecreatefromjpeg($source);
                 $thumb = imagecreatetruecolor($size, $height);
                 imagecopyresampled($thumb, $thumb_s, 0, 0, 0, 0, $size, $height, $w, $h);
                 imagejpeg($thumb, $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext, 100);
             }
         }
     }
     // clean up temp
     $dir = dirname($source);
     unlink($source);
     rmdir($dir);
     // update user's meta
     do_action('um_before_upload_db_meta', $user_id, $key);
     do_action("um_before_upload_db_meta_{$key}", $user_id);
     update_user_meta($user_id, $key, $filename);
     do_action('um_after_upload_db_meta', $user_id, $key);
     do_action("um_after_upload_db_meta_{$key}", $user_id);
     // the url of upload
     return $this->upload_baseurl . $user_id . '/' . $filename;
 }
开发者ID:shramee,项目名称:ultimatemember,代码行数:74,代码来源:um-files.php


示例3: um_can_edit_field

function um_can_edit_field($data)
{
    global $ultimatemember;
    if (isset($ultimatemember->fields->editing) && $ultimatemember->fields->editing == true && isset($ultimatemember->fields->set_mode) && $ultimatemember->fields->set_mode == 'profile') {
        if (is_user_logged_in() && isset($data['editable']) && $data['editable'] == 0) {
            if (um_is_user_himself() && !um_user('can_edit_everyone')) {
                return false;
            }
            if (!um_is_user_himself() && !um_user_can('can_edit_everyone')) {
                return false;
            }
        }
    }
    return true;
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:15,代码来源:um-short-functions.php


示例4: um_user_edit_profile

function um_user_edit_profile($args)
{
    global $ultimatemember;
    $to_update = null;
    $files = null;
    if (isset($args['user_id'])) {
        if (um_current_user_can('edit', $args['user_id'])) {
            $ultimatemember->user->set($args['user_id']);
        } else {
            wp_die(__('You are not allowed to edit this user.', 'ultimatemember'));
        }
    } else {
        if (isset($args['_user_id'])) {
            $ultimatemember->user->set($args['_user_id']);
        }
    }
    $userinfo = $ultimatemember->user->profile;
    $fields = unserialize($args['custom_fields']);
    do_action('um_user_before_updating_profile', $userinfo);
    // loop through fields
    if (isset($fields) && is_array($fields)) {
        foreach ($fields as $key => $array) {
            if (!um_user_can('can_edit_everyone') && isset($fields[$key]['editable']) && !$fields[$key]['editable']) {
                continue;
            }
            if ($fields[$key]['type'] == 'multiselect' || $fields[$key]['type'] == 'checkbox' && !isset($args['submitted'][$key])) {
                delete_user_meta(um_user('ID'), $key);
            }
            if (isset($args['submitted'][$key])) {
                if (isset($fields[$key]['type']) && in_array($fields[$key]['type'], array('image', 'file')) && um_is_temp_upload($args['submitted'][$key])) {
                    $files[$key] = $args['submitted'][$key];
                } else {
                    if (isset($userinfo[$key]) && $args['submitted'][$key] != $userinfo[$key]) {
                        $to_update[$key] = $args['submitted'][$key];
                    } else {
                        if ($args['submitted'][$key]) {
                            $to_update[$key] = $args['submitted'][$key];
                        }
                    }
                }
            }
        }
    }
    if (isset($args['submitted']['description'])) {
        $to_update['description'] = $args['submitted']['description'];
    }
    if (isset($args['submitted']['role']) && !empty($args['submitted']['role'])) {
        $to_update['role'] = $args['submitted']['role'];
    }
    do_action('um_user_pre_updating_profile', $to_update);
    $to_update = apply_filters('um_user_pre_updating_profile_array', $to_update);
    if (is_array($to_update)) {
        $ultimatemember->user->update_profile($to_update);
    }
    if (is_array($files)) {
        $ultimatemember->user->update_files($files);
    }
    do_action('um_after_user_updated', um_user('ID'));
    do_action('um_after_user_upload', um_user('ID'));
    do_action('um_user_after_updating_profile', $to_update);
    if (!isset($args['is_signup'])) {
        $url = $ultimatemember->permalinks->profile_url();
        exit(wp_redirect(um_edit_my_profile_cancel_uri($url)));
    }
}
开发者ID:TeamSubjectMatter,项目名称:juddfoundation,代码行数:65,代码来源:um-actions-profile.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP um_user_profile_url函数代码示例发布时间:2022-05-23
下一篇:
PHP um_user函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap