Admin side I submit form to admin-post.php. I want to print success message in the bottom of the form. Iam new in wordpress what i did shown below.

admin.php?page=add-products form code

 <form action="<?php echo admin_url('admin-post.php') ?>" method="post">
                <input type="hidden" name="action" value="add_product_from_admin">
                <tr><td>Name</td><td><input type="text" name="pr_name" id="pr_name"></td></tr> 
    <tr><td colspan="2" align="center"><input type="submit" name="pr_submit" id="pr_submit" value="Save Products"></td></tr>

    add_action( 'admin_post_add_product_from_admin', 'add_product_into_data_base' );

function add_product_into_data_base() {
    //some database operations

You need to pass variable and it's value in GET method to display success message which you already doing.

Now, in your php file, display message based on GET parameter and its value.

if($_GET['message'] == 'success'){ 
  //display your message 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.