fblanco
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Using AJAXThis has been very helpful! Thanks to you both!
Forum: Developing with WordPress
In reply to: Using AJAXThanks for answering!
Just using jQuery.post instead of ajax apparently worked. I have no idea why hahaha. Would you happen to know what difference it makes?
- This reply was modified 5 years, 8 months ago by fblanco.
Forum: Developing with WordPress
In reply to: Using AJAXI’ll mark this as resolved, since I accidentally double posted.
Forum: Plugins
In reply to: [Code Snippets] Running snippet on button clickSmall update. I’va managed to add this to a snippet:
function testphprun(){ if( isset($_GET['testphprun']) ) { set_time_limit(0); $user_id = get_current_user_id(); $user_info = get_userdata($user_id); $mailadress = $user_info->user_email; $path = file_get_contents('./wp-content/emails/'.$mailadress.'.txt'); $result = ""; exec('py ./wp-content/script.py '.$mailadress.' '.basename($path).'', $result, $return_var); foreach ($result as $line) { echo $line; } } } add_action('init', 'testphprun');So now, whenever I click this button:
<form method="post" action="http://localhost/wordpress/pdfPython/?testphprun"> <input type="submit" value="RunScript"> </form>I get redirected to /localhost/wordpress/pdfPython/?testphprun and the php script runs. I’m sure it’s not the best solution, but it works.
Now I’d like to modify the snippet so that when the page loads, a certain file is downloaded. I tried adding the appropiate headers and a “readfile()” call to this same snippet (after the current code, of course) but that apparently prevents the script from running. It just downloads the file.
- This reply was modified 5 years, 8 months ago by fblanco.
Forum: Plugins
In reply to: [Iptanus File Upload] Run python script with file and user e-mailHello! 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!
Forum: Plugins
In reply to: [Iptanus File Upload] Run python script with file and user e-mailSmall Update.
I managed to get the user’s email using wordpress functions, so that’s done.