• Resolved Georgio

    (@georgio-1)


    Hi @shamim51
    I think that uploads may cause a space problem in the long term, if you have a lot of users.
    How about managing total space per user (or per role)?
    Or not set a space limit but set a time limit. E.g let the admin chose how long attachments will stay in the FEP upload directory.

    Or connect FEP with Buddydrive plugin that manages space per role?

    What are you thinking about?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Shamim Hasan

    (@shamim51)

    Currently you can set how many attachments can be sent with a message, also attachment size can be set. Also you can set how many messages can a user keep in his messagebox. So with this configuration you can easily control your space.

    Thread Starter Georgio

    (@georgio-1)

    Thanks for responding. I have already seen these possibilities in the settings. They allow a relative control, but they are not a real solution in my opinion. So I’ll do it manually, e.g. the 1st of November I am deleting the folder for September and so on.

    Plugin Author Shamim Hasan

    (@shamim51)

    You can add a cron job to automate this process. add following code in your theme’s functions.php

    
    add_action( 'init', 'fep_cus_schedule_event' );
    
    function fep_cus_schedule_event() {
        if ( ! wp_next_scheduled( 'fep_cus_schedule_event' ) ){
    		wp_schedule_event(time(), 'daily', 'fep_cus_schedule_event');
    	}
    }
    
    add_action( 'fep_cus_schedule_event', 'fep_cus_remove_older_files');
    
    function fep_cus_remove_older_files(){
    	$wp_upload_dir = wp_upload_dir();
    	$upload_path = $wp_upload_dir['basedir'] . '/front-end-pm';
    	
    	if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
    		$files = array_filter(glob("{$upload_path}/*/*/*"), 'is_file');
    	} else {
    		$files = array_filter(glob("{$upload_path}/*"), 'is_file');
    	}
    	$now   = time();
    
    	foreach ($files as $file) {
    		if ($now - filemtime($file) >= 3 * MONTH_IN_SECONDS ) { // 3 months
    			unlink($file);
    		}
    	}
    }
    

    It will delete all files older than 3 months. Also please note that if somebody send a message with attachment and later find that his attachment is gone he may find it uncomfortable or may damage valuable information.
    It will just delete attachment files not other attachment data but if anybody go to download that attachment that time full attachment will be deleted including other attachment data.

    Thread Starter Georgio

    (@georgio-1)

    I really appreciate your help. You are exceptional. Thank you very much.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Attachments – Manage total space per user/role’ is closed to new replies.