Shahid Karimi
Shahid Karimi

Reputation: 4357

Is it possible to redirect to our own PHP file in wordpress?

I am developing a plugin in Wordpress. But I have no idea how to post the form data to a PHP file created by me. And how to post, where to place that file? etc etc

Upvotes: 0

Views: 209

Answers (2)

Muhammad Usman
Muhammad Usman

Reputation: 12503

As your question says what you are looking for is not redirecting.

Anyway, you have to create a plugin, I am giving instruction to create a simple plugin. I say again SIMPLE. And its not the only way to create a plugin, but it will be easy one for you.

Create a file in plugins folder and do code like this

/**
 * @package Simple Plugin
 * @version 0.0.1
 */
/*
Plugin Name: Usman
Author: Muhammad Usman
Version: 0.0.1
*/

function showpage($content)
{
    if(stristr($content,'[myplugin]'))
        {
         if(isset($_POST['your-field']))
         {
          //Write your code
          //Save fields or so

          $content="Form submitted";
         }


    }

    return $content;
}

add_filter("the_content","showpage");

Activate this plugin from admin panel and create a page, write [myplugin] in content. And give your form action = this page's permalink.

More details can be found at http://codex.wordpress.org/Writing_a_Plugin

Upvotes: 1

Arpi Patel
Arpi Patel

Reputation: 785

can you explain your answer in more detail? as i have understood your question i can give you answer as,

you can include your page in the plugin page if you want to add that page in the plugin page. and you can post the data in the plugin page by simply using $_POST. if you want to post the data to your php page you can send that as an argument in include page if they are small data

Upvotes: 1

Related Questions