Jump to content

Display message on AdminHomepage via Hook


Recommended Posts

Hello Community,

The following use case should be implemented:

If the admin accepts an order within the admin area, business logic is executed within the "AcceptOrder" hook and if an error occurs, an error message should appear in the "AdminHomepage" template or similar.

Similar to this post:

 

The "AcceptOrder" hook has no return. The only option I have researched is to throw an exception, as in this example:

<?php
//currently
add_hook('AcceptOrder', 1, function($vars) {
  
   //...do business logic
   if($something == "error"){
      throw new Exception("OrderAccept Exception!");
   }  
});



//What I'm looking for
add_hook('AcceptOrder', 1, function($vars) {   
   global $errormessage;  
   
   //...do business logic
   if($something == "error"){
      //.....
      $errormessage = 'ERROR_MESSAGE'; //will show on AdminHomepage or similar
   }  
});

 

Is this possible?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated