Upload file page in Wordpress and reponse there - php

I'm a beginner in PHP but an expert in programming in general, so I program C and C++ usually, but I have no experience with posting and getting with PHP, so I don't really understand the exact mechanism how this works.
Yesterday I worked for like two hours on my webserver and set a page on my Wordpress to make visitors upload a file. The page submits a form to a custom PHP page, but that page is empty and dull, and I would like to make the confirmation page in Wordpress itself. What I tried to do for that is that I created a new page, and used the plugin "insert PHP", and simply pasted the code from the page, to which the form submits, and made my upload form post to that Wordpress page. This doesn't seem to work.
How can I get this to work?
Simplifying the question: How can I make my form in wordpress post to another wordpress page and give the response in a wordpress page rather than a PHP page created from scratch?
If my question is not clear or requires any additional information to be answered, please let me know.
Thank you.

You're going to want to get to know specialized page templates in WordPress, and the page templating system in general. Ideally, you'd create a page in wp-admin and create a specialized page template for it.
If you're doing form processing, you can do that in the new template...but may be better off moving that logic to the functions.php file. Use action hooks to ensure that your processing functions are run on submit.

Related

Manipulate data after Contact form 7 is submited

I have contact form 7, form in my Wordpress site.
I want when form is submitted (and mail has sent) to pass via post method, the data to onother PHP file. In my last PHP file I have code to send form's data to a CRM system.
I have searched over the internet for a solution. Some people say its easy some other not. But at the end there isn't any example on how to do that.
Also I did not found anything in CF7 documentation.
What I found is hook and actions.
The only logical solution I found is that in this link .
But I don't understand where to put the code and how to call it.
The best way is to create a custom Plugin. Then you can add the code listed in your link to your Plugin code.
A guide to Plugin development can be found here. A good Plugin template to get you started can be downloaded from here.

Generate link to clone or duplicate a post from wordpress frontend

I've found a number of plugins for wordpress that add a link to the table in the backend to clone or duplicate a post or page (Duplicate Post, Clone Post, and Post Duplicator). This is nice, but I'm building a bit of an app on wordpress where I'm using a custom post type as an entry and would like to be able to quickly copy an entry with a link from the frontend of the site (similar to how edit_post_link works but without jumping into the backend).
I'm using Gravity Forms for the create and edit functionality for entries on the frontend, but I can't quite figure out the best approach for a secure way to submit a request, execute the clone query, and the return to the same page I was on before (i.e. not jumping into the backend). Gravity Forms Post Updates plugin does something similar with a do_action call to generate a link. I've looked through this function and generally get what's happening, but I'm not sure if I need all of the extra plugin class structure.
I was hoping to find an example of a function that could create a secure url with a nonce and then another function we validate the url and execute the query and return to the previous page. Is this the right way to go or am I barking up the wrong tree? If so, any code samples or examples that might be able to help get me started?
Much appreciated!
I found this post (http://rudrastyh.com/wordpress/duplicate-post.html) and was able to figure out what I needed to. Instead of adding a filter to include the link in the backend, I instead created an action that can be called with do_action and generates the link. I also have a page and page template that is solely for executing the call and then redirecting back to the referring url.

How to take my PHP form handler pages into WordPress to connect with PayPal API

I'm trying to integrate a form like this into Wordpress
This form works perfectly with the PayPal API sandbox. However, when I tried to move this work over to the WP site of my organization, globalcitizenyear.org/donate/donation-form-2/, I keep coming up short.
Anyone have any tips to keep in mind when doing this? What steps would you take first to make this happen in Wordpress - any details on what to avoid, or what potential hangups might be?
Make a page called page-donation-form-2.php and load this code into it. You can leave in the get_header() and get_footer() tags if you want to have the site wrapper around the outside.
Make sure to change your form action also. And remember, that since this is in WordPress now, you will need to avoid some reserved form elements. Full list here.
If you have any trouble, please post your code here.

Quickpost form on Drupal front page

Hey, I'm quite new to Drupal and am having some issues with implementing a node form on the front page of the site.
I want to have a really simple quick post form on the users front page when they are logged in, just a few fields and a submit button, no advanced options or anything.
Is there a really simple way to do this by placing some php in the front-page.tpl.php file?
I think what you are looking for is http://drupal.org/project/webformblock. (also requires the webform module)
Create a region on the front page and just put this block in it. You can set options in the block to only appear on the front page.
Or you could just invoke the block directly in the tpl.php file.
http://drupal.org/node/26502
Yes and no. This is not the drupal way of doing things- although you COULD make it work this way.
If you are looking for a simple solution, try a module like webform and put it on the front page. You can do this by either creating a page and setting it as the front page (under site information in the admin menu), or by creating a block, putting it in the 'content top' region of your theme, and in the configure block setting it only to display on (a special keyword that means frontpage).
Hope this helps!
Chris.
If your login goes to the /user page you can use the webformblock module (http://drupal.org/project/webformblock) to configure a Webform to only show up on the "user" page under site building > blocks > configure (next the the webform block). You can also check the option there to only show the block for authenticated users or another role of your choice.
You do not want to create a form without going through Drupal's form API, as you lose a lot of security features and there are many tools out there already that make it easy to generate and maintain forms through the Drupal interface. As the above answers suggest, webform is the Drupal way to create quick forms. And I think you will love the interface.
http://drupal.org/project/webform
Thanks for all your help guys. I tried the webformblock module and whilst it did fit the bill, it required me to create a new content type (maybe I wasn't using it right?).
In the end, after searching I found the Form Block module http://drupal.org/project/formblock which fitted my needs perfectly. It can be configured for existing content types really easily.

WordPress - PHP Code Box

I am very new to WordPress, so I would appreciate some help.
I am using WordPress as a CMS, and I am trying to make the thing work so that when I select a page to edit, there is a special box where I can input PHP code that will execute on my page.
I have found the PHP exec plugin, which works perfectly, but I would like to keep the code out of my main text editor, out of the way of my client's careless fingers.
Any suggestions would be very, very appreciated. Thanks!
You could create a template for each one, and include your PHP there.
Simply select the template from the page edit page.
But if you are only including a little PHP per page, you could get the slug via WordPress in your page template and act on it accordingly.
You can also add an extra meta box on the post editor page, only visible to you, with a textarea where you can add the code. You would save it as a meta field of the post. Your template can check for the existence of this field, and execute it if found.
PHP Exec is the best plugin I have found, and I looked long and hard for that one. The problem with doing it as you suggest is that if the PHP code displays an item on the page, it still has to be formatted within the page as well. It is a simple logistical problem, but somewhat of a complex coding problem. I haven't been able to get around to working on creating a better plugin for it.

Categories