I have set up the following action to fire when a form's POST data is submitted:
add_action( 'admin_post_trukey_leg', array( 'Libhours', 'cp_libhours_turkey_leg' ) );
Here is the function:
public static function cp_libhours_turkey_leg(){
status_header(200);
die("Server received '{$_REQUEST['data']}' from your browser.");
}
And here is the form which is supposed to trigger the action:
<form method="post" action="<?php echo admin_url('admin-post.php'); ?>">
Area Name: <input type="text" name="new_area_name" value="<?php echo $area_name[0]->location; ?>" required><br>
URL (optional): <input type="text" name="new_area_url" value="<?php echo $area_name[0]->url; ?>"><br>
Note (optional): <textarea rows="3" name="new_area_note"><?php echo $area_name[0]->note; ?></textarea><br>
<input type="hidden" name="action" value="turkey_leg">
<input type="submit" value="Edit Area">
</form>
The form properly submits to admin-post.php and goes into the proper part of the loop (I confirmed this by simply echoing something out if it was in that part of the loop), but the action does not fire.
Aucun commentaire:
Enregistrer un commentaire