Run python script with file and user e-mail
-
Hello!
I have an issue similar to this one.
Im trying to run a python script that takes the uploaded file and the user’s e-mail as input.
if (!function_exists('wfu_after_upload_handler')) { function wfu_after_upload_handler($changable_data, $additional_data) { $files = $additional_data["files"]; $result = ""; foreach ( $files as $file ) if ( $file["upload_result"] == "success" || $file["upload_result"] == "warning" ) { $file_path = $file["filepath"]; exec('python path/to/script.py', $result, $return_var);; break; } if ( $result != "" ) foreach ($result as $line) { $changable_data["js_script"] = 'console.log("'.$line.'");'; } return $changable_data; } add_filter('wfu_after_upload', 'wfu_after_upload_handler', 10, 2); }For now, the script is a simple helloworld just for testing, but I’ve been unable to make it work. I’m new to php and WordPress so my questions may be a bit silly, but here they are:
1) Is path/to/script.py relative to wp-content?
2) Eventually I’ll need to get the logged user’s email (or some kind of user data). I assumed it should be somewhere in ‘$additional_data[user-data]’. I tried using this
console.log("'.$additional_data["user_data"].'");to take a look inside ‘user_data’ but I’m sure I’m doing something wrong, since it’s not working.
I’m using the free version of the plugin.
Thanks in advance! Any help will be greatly appreciated!
The topic ‘Run python script with file and user e-mail’ is closed to new replies.