How to fetch forms data submitted in a wordpress plugin file?

时间:2015-06-26 10:15:50

标签: php wordpress forms

I want to submit a form which contains a textarea to my Wordpress plugin. But I don't know exactly HOW. I want my plugin to fetch the $_POST variable after the submission of the form that I create for it. The other idea would an setting fields. Having setting fields to save some data in it then accessing them via plugin. All in all, I want to be able to access the setting form, input, textarea and other form elements values through my Wordpress plugin. I know the question sounds novice, I couldn't find any search result regarding my question.

1 个答案:

答案 0 :(得分:1)

我会在你的插件中创建一个函数并将其添加到init action hook中。这是截取$_POST数据并与您合作的好时机。

function intercept_post_data() {
    // do things with the $_POST array
}
add_action( 'init', 'intercept_post_data' );

但是,通过将表单的POST更改为指向处理表单处理的插件文件,您还可以选择action直接插入您的插件。 (我推荐第一个选项)。