Out of the box, USP Pro is tightly integrated with the WordPress Media Library. This means that any/all files submitted via USP Pro forms are uploaded to the default directory, /wp-content/uploads/ or something like /wp-content/uploads/2024/01/ if you have enabled the WordPress option to “Organize my uploads into month- and year-based folders”. That’s great for most cases, but there may be a scenario where you want to keep submitted files separate from your non-submitted files. This quick tutorial explains two ways to create a custom directory for all files uploaded via any USP Pro Form.

Custom directory via wp-config.php

With USP Pro, you can define a custom directory located within the /uploads/ directory. Simply add this line to the wp-config.php file:

define('USP_UPLOAD_DIR', '/custom/');

Here we are defining a constant with the name of our custom uploads directory. Change “custom” to whatever you prefer. Also important is to make sure that the directory /uploads/custom/ exists on your server with suitable permissions. Currently this technique only works when the option “Organize my uploads into month- and year-based folders” is not selected.

Custom directory via plugin

If you would rather not add a line to your wp-config.php file, here is the same method implemented via must-use plugin. Just create a blank PHP file named mu-usp.php (or whatever you prefer) and add the following slab of code:

<?php
/*
	Plugin Name: USP Pro - Custom Uploads Directory
	Description: Define and enable custom upload directory and permissions for USP Pro.

	To enable custom uploads directory for USP Pro:
		1. Create a new directory in the /uploads/ directory
		2. Give that directory proper permissions (ask your host)
		3. Replace the "usp" in the path below with the name of your new directory
		4. Done! USP Pro will auto-detect the new directory and use it for all uploaded files.

	Note: Subdirectory (e.g., "/usp/sub/") is allowed if given the proper permissions!
*/
define('USP_UPLOAD_DIR', '/usp/'); // default custom path = "/usp/"

Then upload the file to a directory named mu-plugins located in the wp-content directory. So the final must-use plugin will reside at:

/wp-content/mu-plugins/mu-usp.php

After uploading the plugin, test well before going live with the functionality.