Jump to content
Sign in to follow this  
sol2010

Hook Error with array

Recommended Posts

I am using this hook to get additional notifications when a support department ticket is opened.  However, after upgrade to PHP 8.1 and the new WHMCS version, I am getting an error;

 
I'm getting an error from the code  ' if (in_array($departmentid, $criticaldept)) { '  (line 26) 
 
Something went wrong and we couldn't process your request.
Please go back to the previous page and try again.
 
TypeError: in_array(): Argument #2 ($haystack) must be of type array, int given in /home/ domain  /public_html/clients/includes/hooks/emergencyticket.php:26
 
Here is the relevent code... why is the array an issue ?
 
function hook_send_emergency_email($vars) {
  
  $criticaldept = 5; // id of emergency department
  $departmentid = $vars['deptid'];
  $company = $vars['companyname'];
    
    if (in_array($vars['deptid'], $criticaldept)) {

 

 
 
Edited by sol2010

Share this post


Link to post
Share on other sites
10 hours ago, sol2010 said:

Here is the relevent code... why is the array an issue ?

Because that's not an array. 
Try: 

$criticaldept = array('5'); // id of emergency department

 

Share this post


Link to post
Share on other sites

i get this error

TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /var/www/vhosts/

  if (!in_array("error", $result)) {
                logModuleCall("Xtream UI ONE", "Custom Fields", "Custom Fields Created", $custom_fields);
            }

anyone can help me with this?

Share this post


Link to post
Share on other sites

Since $result isn't defined in the code this was about, your code is likely not the same. Can you show your code?

Share this post


Link to post
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.

Sign in to follow this  

  • 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