APD Toronto
asked on
Reading $_POST within WP-Admin
Hi Experts,
I am trying to write a very simple plugin for my client, and this is my first plugin, but cannot figure out how to submit from within /wp-admin?
As a test , I put together the following, but when I submit I get 404 Error. I see this is because the submit action is looking for .../wp-admin/admin-submit. php where admin-submit.php is in my plugins folder, but if I submit directly to it, I know I will get out of the wp-admin structure. Do I need to doeverythign in iFrame or how do I handle this properly?
aces-test.php
admin-form.php
admin-submit.php
Any help will be greatly appreciated.
I am trying to write a very simple plugin for my client, and this is my first plugin, but cannot figure out how to submit from within /wp-admin?
As a test , I put together the following, but when I submit I get 404 Error. I see this is because the submit action is looking for .../wp-admin/admin-submit.
aces-test.php
<?php
/**
Plugin Name: Aces Test
Plugin URI: https://www.aces-project.com
Description: This is my <b>Plugin</b> description.
Version: 1.0.0
Author: Aleksandar Poposki
Author URI: https://www.aces-project.com
**/
function wp_add_menu(){
// add_menu_page('ACES Page Title', 'ACES Options', 'manage_options', 'aces_plugin', '', 'dash-email-alt');
$admin_page = 'admin-form';
add_menu_page(
'Custom Menu Title',
'custom menu',
'manage_options',
$admin_page, 'aces_admin',
'');
}
function aces_admin(){
require_once 'admin-form.php';
}
function aces_activate(){
//Create WP-Admin Page
//echo 'ok';
}
// Activate
register_activation_hook(__FILE__, 'aces_activate');
add_action('admin_menu', 'wp_add_menu');
function aces_shortcode(){
$disp = "ACES <b> plugin </b> from nnethbeans.";
return $disp;
}
add_shortcode('aces-plugin', 'aces_shortcode');
?>
admin-form.php
<?php
/*echo '<div id="divAdmin" style="display:inline-block; height: 500px; background-color: yellow">
xxxxxxxx
</div>';*/
?>
<div id="divAdmin" style="display:inline-block; height: 500px; background-color: yellow">
<form action="admin-submit.php" method="post">
name: <input type="text" name="txtName">
<input type="submit">
</form>
</div>
admin-submit.php
<?php
$name = $_POST['txtName'];
echo 'Are you sure your name is ' . $name . '?';
Any help will be greatly appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.