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
    foreach ($fields as $key => $array) {
        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'])) {
        exit(wp_redirect(um_edit_my_profile_cancel_uri()));
    }
}
Пример #2
1
 function delete_file($src)
 {
     if (strstr($src, '?')) {
         $splitted = explode('?', $src);
         $src = $splitted[0];
     }
     $is_temp = um_is_temp_upload($src);
     if ($is_temp) {
         unlink($is_temp);
         rmdir(dirname($is_temp));
     } else {
         die('Not a valid temp file');
     }
 }
Пример #3
1
 function update_files($changes)
 {
     global $ultimatemember;
     foreach ($changes as $key => $uri) {
         $src = um_is_temp_upload($uri);
         $ultimatemember->files->new_user_upload($this->id, $src, $key);
     }
 }
Пример #4
1
 function delete_file($src)
 {
     if (strstr($src, '?')) {
         $splitted = explode('?', $src);
         $src = $splitted[0];
     }
     $is_temp = um_is_temp_upload($src);
     if ($is_temp) {
         unlink($is_temp);
         rmdir(dirname($is_temp));
     } else {
         wp_die(__('Ultimate Member: Not a valid temp file', 'ultimatemember'));
     }
 }