本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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)));
}
}