I'm beginning with creating plugins and I don't quite understand the process of displaying error messages. e.g. I use the php readfile function to download a file from a hidden location. If something goes wrong e.g. the file isn't found, how do you display a message at that moment.
I know you need to use add_action for 'admin_notices' but I can't quite figure out where you are supposed to put the add_action calls.
As far as I can tell, you have to create a function my_download_file which tries the download and echo's a
<div class="error">. Then 'somewhere' you need to call
add_action('admin_notices', 'my_download file');.