Exemple #1
0
 function handle_upload($name = '', $action = '')
 {
     $uploaded_file = BPCP_Utils::handle_upload($name, $action);
     //if file was not uploaded correctly
     if (!empty($uploaded_file['error'])) {
         bp_core_add_message(sprintf(__('Upload Failed! Error was: %s', 'buddypress'), $uploaded_file['error']), 'error');
         return false;
     }
     //assume that the file uploaded successfully
     //delete any previous uploaded image
     $this->delete_cover($this->group_id);
     //save in user_meta
     groups_update_groupmeta($this->group_id, 'bpcp_group_cover', $uploaded_file['url']);
     groups_update_groupmeta($this->group_id, 'bpcp_group_cover_file_path', $uploaded_file['file']);
     @setcookie('bp-message', false, time() - 1000, COOKIEPATH);
     do_action('bpcp_group_cover_uploaded', $uploaded_file['url']);
     //allow to do some other actions when a new background is uploaded
     return true;
 }
 function handle_upload()
 {
     $uploaded_file = BPCP_Utils::handle_upload();
     //if file was not uploaded correctly
     if (!empty($uploaded_file['error'])) {
         bp_core_add_message(sprintf(__('Upload Failed! Error was: %s', 'buddypress'), $uploaded_file['error']), 'error');
         return false;
     }
     $user_id = bp_loggedin_user_id();
     if (is_super_admin() && !bp_is_my_profile()) {
         $user_id = bp_displayed_user_id();
     }
     //assume that the file uploaded successfully
     //delete any previous uploaded image
     self::delete_cover_for_user($user_id);
     //save in user_meta
     bp_update_user_meta($user_id, 'profile_cover', $uploaded_file['url']);
     bp_update_user_meta($user_id, 'profile_cover_file_path', $uploaded_file['file']);
     @setcookie('bp-message', false, time() - 1000, COOKIEPATH);
     do_action('bpcp_cover_uploaded', $uploaded_file['url']);
     //allow to do some other actions when a new background is uploaded
     return true;
 }