I have a custom Wordpress plugin that handles many things including download pages for my products. The links are not the path to the actual PHP page to my plugin. For example...
http://myurl.com/download/product
But the path to my plugin that actually handles the download function is this path:
http://myurl.com/wp-content/plugins/myplugin/myplugin.php
I have built an app that uses these download links to grant a user the ability to download a product after purchase. But now I need to send extra data along with the url. How can I send some additional $_POST data when the users click on the download link. I have tried
http://myurl.com/download/product?id=2345&user=tom
But when I try to echo out the variables in myplugin.php I get nothing.
echo $_GET['id'];
echo $_GET['user'];
I have also tried to use a form and send hidden inputs but still the same result.
Any help would be greatly appreciated.
Create a new shortcode (maybe empty that does nothing) and put it on some page you created from WordPress.
Then, form action will be the URL to new page where you send data you need to send and method will be post.
You can handle the data you sent in new shortcode function in your plugin using $_POST['data']
This might help you as an alternative solution.
Related
I have created a module where a form is added to the admin view order page using the function:
public function hookDisplayAdminOrderSide($params)
The form on that page posts data to the same url:
<form method="POST" action="#">
I then use the hook "hookDisplayAdminOrderTop" to capture the post data and submit to the API (this is done when the page posts to itself and reloads). I then collect the results of the api and assign it to $result. This then allows me to echo if the submission worked etc
This all works fine.
However, I'm pretty sure this is not the correct way to do this with Prestashop. Usually with a form I would send the user to another page e.g.
<form method="POST" action="/submit.php">
Then on that page once the data has been submitted, redirect the user to a confirmation page.
Whilst what I have done is working, what is the correct way to do this with prestashop (p.s. I'm new to Prestashop, this is my 1st module) so try and keep the advice easy to follow?
I looked at the other forms on the page e.g. status update form and private note form, they all seem to post to the same url but with a slight change e.g.
index.php/sell/customers/2/set-private-note
index.php/sell/orders/2/status
index.php/sell/orders/2/send-message
I'm assuming the "set-private-note" and "status" etc are linked to some form for submission form in the PS back end.
Finally, on a second note, if you create a 2nd php file in the module root folder, what needs to be added to keep this secure e.g. so someone outside of the admin can't run it etc?
Any help would be greatly appreciated.
Thanks in advance :)
I have a WordPress site that is used as a news portal to generate traffic for my clients (leads). I want the ability to add a custom HTML code with the form in it.
The posted data (the form structure) contains several parameters that needs to be changed in each blog post in order to send the data to the relative campaign in my crm.
Form should display perfectly in mobile as well, thank you page is handled by the form attributes so no need to worry about that.
any tips?
There must be a standard answer to this question which must come up all the time, but I haven't been able to find the solution.
I am trying to set up the return page from a PayPal payment on a Wordpress site. I have a button on the sales page which sends the transaction to PayPal and once completed PayPal sends POST data back to a url for a page that I specify on my site.
The responding page on my site needs to perform a confirmation handshake with PayPal, read the POST data, email me with the details, and display a table to the customer with the details. All except the last action can easily be done with php, but displaying the table (which should be the easiest) is where I'm stuck.
I have a draft "Thank you for your order" page on standard page in Wordpress. I have created a custom template file which can be selected from the Templates dropdown selector on the Edit page. The custom template can host the php code to perform the handshake, get the POST data and email me with the details.
However, the template (which is a copy of the Atahualpa theme's index.php file) renders the page by various Wordpress function calls, and I don't want to interfere with those. However, this means that I can't directly control the page rendering using echo commands in php. With javascript or jquery I could allow the page to load and then modify the innerHtml, but this seems to be a clumsy way of doing it, and it would probably be visible to the user, as page elements are first rendered then modified.
What's the best way to do this?
I'm transitioning from CodeIgniter to WordPress. Still trying to wrap my head around WordPress plugin development... seems pretty easy, but one thing I can't figure out is: where do I send the form data? In CodeIgniter, you could simply create another method in the controller and point the form action there, but it seems WordPress plugins are a little different.
Depends on how your plugin is generating the form. Typically you do it by registering a shortcode, something like [my_form] that you can insert into a page or post where you want the form to appear.
In your plugin code the form action can be blank -- simply reload the same Wordpress page. Your form info. will be in the global $_POST and your plugin can then process the data.
So your plugin shortcode function would have something like:
if(isset($_POST['my_plugin_form_field'])){
/* code to process the form info and generate a message on screen
}
else{
/* the form hasn't been submitted yet so here is the code to display it
}
I am not a php programer and don't know anything about data fetching, but i am trying to make a template that loads the custom field values of the post via ajax in wordpress the reason i would like to load the values using ajax is because those fields contain lot of texts and image links so if they preloaded it will take lots of time to load whole page.
I wrote a plugin for you! First download and install ajax-custom from the URL below. When the plugin is activated, insert the following template tag in your theme everywhere you need these AJAX-loaded custom-fields. Don't forget to replace NAME OF THE FIELD with the actual name of the custom field you want to load via AJAX.
<?php
if( function_exists( 'ac_placeholder' ) )
ac_placeholder( 'NAME OF THE FIELD' );
?>
→Download ajax-custom
I hope it helps you and maybe also someone else. I would appreciate a thumbs up. :)