• I’m displaying the file list on a page with the [user_file_manager]
    shortcode. I want to display by the date they were uploaded/updated.

    I added a timestamp field to userfile_data table.

    I don’t see where in the functions.php or user_files.php where I can change the sort order… by adding something like ORDER BY ‘dateTime’ DESC

    Is it possible?

    https://www.ads-software.com/extend/plugins/user-files/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Scriptonite

    (@scriptonite)

    The dates are not saved in the database, however since the plugin is driven by file folders instead of the database, you can create an array of the files first, sort by date, then run the file array through the function to list them. Hope this helps.

    in functions.php, create new function, list them in array.

    ##########################
    # My List User Files        #
    ##########################
    function MyListUserFiles($files,$userID,$fl) {
    	global $wpdb;
    	global $post;
    	$c = 1; //why c is created and defined as 1?
    	// foreach is used to list file
    	foreach($files as $Thefile) {
    		$ext = pathinfo($Thefile['file'], PATHINFO_EXTENSION);
    		$tExt =  SetIcon($ext); // for the icon
    		$rowClass = ($c++%2==1)?'odd_files':'even_files'; // what does this mean?
    		echo '<td class="'.$rowClass.'" align="center"><img src="'. $tExt.'" width="20" style="margin-top: 5px; margin-bottom: -5px; -webkit-box-shadow: inset 0px 0px 10px 0px rgba(3, 156, 212, 0.14); box-shadow: inset 0px 0px 10px 0px rgba(3, 156, 212, 0.14);"></td>';
    		// Document Description
    		echo '<td class="'.$rowClass.'" width="50%" style="font-weight: bold; font-size: 12px;">'.pathinfo($Thefile['file'], PATHINFO_FILENAME) .'</td>';
    		// Date Uploaded
    		echo '<td class="'.$rowClass.'" align="center" width="60px">'. GetTimeStamp($Thefile['file'],$userID)  .'</td>';
    		// Category
    		echo '<td class="'.$rowClass.'" align="center" width="60px">';
    		$currOpts_defcat = get_option('file_manger_defaultcat');
    		$getCrntCat = $wpdb->get_var("SELECT category FROM ". $wpdb->prefix . "userfile_data WHERE filename = '".$Thefile['file'] ."' and user_id='" .$userID. "'");
    		if (!$getCrntCat) {
    			echo $currOpts_defcat;
    		}else{
    			echo $getCrntCat;
    		}
    		echo'</td>';
    		if (strpos(curPageName(),'?') ==false){
    			$dnlLink = curPageName().'?theDLfile='.$userID.'/'.$Thefile['file'];
    			$DelLink = curPageName().'?deletefile='.$userID.'/'.$Thefile['file'];
    		}else{
    			if(!$post->ID){
    				$DelLink = curPageName().'&deletefile='.$userID.'/'.$Thefile['file'];
    				$dnlLink = curPageName().'&theDLfile='.$userID.'/'.$Thefile['file'];
    			}else{
    				$DelLink = '?page_id='.$post->ID.'&deletefile='.$userID.'/'.$Thefile['file'];
    				$dnlLink = '?page_id='.$post->ID.'&theDLfile='.$userID.'/'.$Thefile['file'];
    			}
    		}
    		// Download
    		echo '<td class="'.$rowClass.'" width="80px"><span  class="user-files-download"><a  href="'.$dnlLink.'">Download</a></span>';
    		// Delete
    		if(get_option('file_manger_allow_del')=='yes') {
    			echo '<td class="'.$rowClass.'" align="center"><a href="'.$DelLink.'" class="user-files-delete">Delete</a></td></tr>';
    		} else {
    			echo '</td></tr>';
    		}
    	}
    }
    
    function cmp($a, $b) {
            return $b["created_at"] - $a["created_at"];
    }

    In user-files.php, call them using this

    MyListUserFiles($files,$current_user->ID,$count);

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can you change order files are displayed?’ is closed to new replies.