Automated File upload and assign user
Hello, Great product. I wondered if there is a way of automating assignment/owner of a file via an api/curl command or database access? I basically have another system which generates reports for a user – when its complete I want it to automatically “upload” the report and assign it to the user. At the moment the only way I could see of automating it would be via selenium or some automated “click here, click here” script – but that would be clunky and potentially unreliable.
I think that the simplest way would be to send the files you want to assign to a folder in your FTP (something like wp-content/customer-area/ftp-auto-uploads for instance).
Then, you’ll need to write a PHP script that will scan those files in that folder in order to create private files posts, and automatically assign them to the owners (it means that the owners’ IDs should be included in the filename for instance). We have some functions like cuar_bulk_create_private_files that should help you to automatically create the private files posts.
This kind of process would be very specific to your needs, and we don’t actually have an add-on allowing you to do that out of the box. You’ll probably need to hire a developer to do that for you if you don’t have the required development skills. However, someone gently shared a script he made on GitHub. I’ve never tested it, I can’t tell you if it works or not, however, it could be a good starting point for you to understand what can be done.
From what I understand by reading its code, the script creates a new WP-admin setting page to allow you to scan the wp-content/customer-area/ftp-uploads folder (I recommend using another folder name by the way). The script shows owner fields to allow you to select the owners manually (actually users or user groups), and make sure the imported file is a PDF file.
This method still requires a manual process since it requires that you select an owner from a field.
However, if you want to automate that even more, you could for instance simply create a PHP script that would be executed through a CRON command. If you include owners’ IDs in the filename, you could create a script that should be able to extract the owners from the filename using a Regex. Your script wouldn’t be the exact same as the one given in the example, because your requirements seem different, but it should be doable with some custom development.
I hope that helps.
The topic ‘Automated File upload and assign user’ is closed to new replies.