Title: Run python script with file and user e-mail
Last modified: September 17, 2020

---

# Run python script with file and user e-mail

 *  Resolved [fblanco](https://wordpress.org/support/users/fblanco/)
 * (@fblanco)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/run-python-script-with-file-and-user-e-mail/)
 * Hello!
 * I have an issue similar to [this one](https://wordpress.org/support/topic/changing-file-paths-and-using-them-after-upload-is-done/).
 * 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!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [fblanco](https://wordpress.org/support/users/fblanco/)
 * (@fblanco)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/run-python-script-with-file-and-user-e-mail/#post-13424322)
 * Small Update.
 * I managed to get the user’s email using wordpress functions, so that’s done.
 *  Plugin Author [nickboss](https://wordpress.org/support/users/nickboss/)
 * (@nickboss)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/run-python-script-with-file-and-user-e-mail/#post-13429068)
 * Hi, are you sure that your system allows to execute exec function?
 * Put PHP command `error_log($file_path);` above exec command to check that the
   block is executed. You should see output at /wp-content/debug.log file.
 * Regards
 * Nickolas
 *  Thread Starter [fblanco](https://wordpress.org/support/users/fblanco/)
 * (@fblanco)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/run-python-script-with-file-and-user-e-mail/#post-13434024)
 * Hello! Yes, it does!
 * In the end I managed to use full paths and then moved on to relative paths once
   I figured what the root directory was.
 * Thanks for your reply!
 *  Plugin Author [nickboss](https://wordpress.org/support/users/nickboss/)
 * (@nickboss)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/run-python-script-with-file-and-user-e-mail/#post-13438407)
 * Ok nice.
 * Regards
 * Nickolas

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Run python script with file and user e-mail’ is closed to new replies.

 * ![](https://ps.w.org/wp-file-upload/assets/icon-256x256.png?rev=3252590)
 * [Iptanus File Upload](https://wordpress.org/plugins/wp-file-upload/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-file-upload/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-file-upload/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-file-upload/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-file-upload/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-file-upload/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [nickboss](https://wordpress.org/support/users/nickboss/)
 * Last activity: [5 years, 8 months ago](https://wordpress.org/support/topic/run-python-script-with-file-and-user-e-mail/#post-13438407)
 * Status: resolved