WordPress的。我如何在php中查看和发送get / post请求?
此插件的代码无效:
我写了这个插件。它是所有的源代码。
插件的文件index.php
此功能可以在激活插件上启动:
function activate() {
// registration
$post = array(
//'ID' => 15, // Are you updating an existing post?
'post_content' => '
<form action="#" method="post">
<p>
<label for="username">username: </label>
<input type="text" id="username" /><br />
<label for="nick">password: </label>
<input type="text" id="password" /><br />
<label for="password_repeat">repeat_password: </label>
<input type="text" id="repeat_password" /><br />
<label for="email">Email: </label>
<input type="text" id="email" /><br />
<label for="age">Возраст </label>
<input type="text" id="age" /><br />
<input type="submit" value="Enter">
</p>
</form>
', // The full text of the post.
'post_name' => 'reg', // The name (slug) for your post
'post_title' => 'reg', // The title of your post.
'post_status' => 'publish', // Default 'draft'.
'post_type' => 'page', // Default 'post'.
);
$post_id = wp_insert_post( $post, $wp_error );
}
register_activation_hook( __FILE__, 'activate' );
function market () {
$user_login = $_POST['user_login'];
$user_pass = $_POST['user_pass'];
$test = "testesttest";
return $test;
}
//add_action( 'init', 'register_form' );
add_action( 'get_header', 'market' );
答案 0 :(得分:0)
查看帖子并获取请求,您可以使用调试栏插件: https://wordpress.org/plugins/debug-bar/
答案 1 :(得分:0)
我需要在我的PHP代码中使用它:
function sitemarket () {
if ( 'POST' != $_SERVER['REQUEST_METHOD'] ) {
header('Allow: POST');
header('HTTP/1.1 405 Method Not Allowed');
header('Content-Type: text/plain');
exit;
}
nocache_headers();
var_dump($_POST);
$comment = isset($_POST['username']) ? $_POST['username'] : "";
var_dump($comment);
//$test = authentication("user123","user951");
$test = "testesttest";
return $test;
}
//add_action( 'init', 'register_form' );
add_action( 'get_header', 'sitemarket' );
为什么POST REQUEST = NULL?