Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have created a form. On success of the form, I am redirecting the user the their dashboard. Now, I want to be able to show a success message/notice on the dashboard.

What is the convention to show such messages ?

share|improve this question
    
Have you tried our search engine? –  toscho Dec 10 '12 at 20:44
    
Are you using Settings API? –  Mamaduka Dec 10 '12 at 22:39
    
@toscho I did but had misunderstood the function. Thanks. –  Prakash Raman Dec 11 '12 at 9:54
    
@Mamaduka if you mean the options page, I have. Thanks. –  Prakash Raman Dec 11 '12 at 9:54
add comment

1 Answer

up vote 1 down vote accepted

When you redirect the user to the admin dashboard pass on a GET variable named "success_notice", for example. So you get a URL like this: /wp-admin/index.php?success_notice=1.

With that setup, just add the code that shows the success message on the dashboard only if that GET variable is set.

add_action('admin_notices', 'wpse75629_admin_notice');

function wpse75629_admin_notice()
{
    global $pagenow;

    // Only show this message on the admin dashboard and if asked for
    if ('index.php' === $pagenow && ! empty($_GET['success_notice']))
    {
        echo '<div class="updated"><p>Your success message!</p></div>';
    }
}
share|improve this answer
    
Thank you, had misunderstood the function of the "admin_notices" hook. –  Prakash Raman Dec 11 '12 at 9:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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