Jump to content

getting {$whmcs_admin_url} in hooks


snake

Recommended Posts

disclaimer: I am not a PHP developer, I have put this together just by looking at other people's code and the docs.

 

I have a hook that sends out an email to all dept staff whenever a note is added to a ticket.

It is working fine, except for the LINK to the ticket, I am using this.

 

"ticket_link" => "http://{$whmcs_admin_url}supporttickets.php?action=view&id={$tid}"

 

but {$whmcs_admin_url} doesn't seem to exist in this context, I found this in the email templates, how do I access this value froma hook?

Link to comment
Share on other sites

my first thought when I saw that code was... why not just hardcode the URL?? i'm working on the assumption that you already know your own admin URL! :)

 

second thought is wondering why you were trying to use Smarty variables in that way in a hook - just because a variable exists in an email template, doesn't mean that it's accessible elsewhere.

 

if it were me, i'd just hardcode the URL in the variable and then see if id passes the correct ticket ID value. :idea:

Link to comment
Share on other sites

my first thought when I saw that code was... why not just hardcode the URL?? i'm working on the assumption that you already know your own admin URL! :)

I could do that, but that would be lazy coding, and I wanted to put the hook up on the marketplace for others to use, and doing that would mean the code won't work anywhere else without manually changing the code.

 

 

second thought is wondering why you were trying to use Smarty variables in that way in a hook - just because a variable exists in an email template, doesn't mean that it's accessible elsewhere.

Go back and read the very first line of my first post.

 

if it were me, i'd just hardcode the URL in the variable and then see if id passes the correct ticket ID value. :idea:

While I may not be a PHP developer, but I do have a background in programming on other languages, and I have never been one for lazy coding and bad practices, see my answer above, so I would rather do it properly and start as I mean to go on.

Link to comment
Share on other sites

I could do that, but that would be lazy coding, and I wanted to put the hook up on the marketplace for others to use, and doing that would mean the code won't work anywhere else without manually changing the code.

Go back and read the very first line of my first post.

aaah I took from the first line that this was for personal use and therefore couldn't understand why you had ignored the obvious solution... now it makes sense! :)

 

While I may not be a PHP developer, but I do have a background in programming on other languages, and I have never been one for lazy coding and bad practices, see my answer above, so I would rather do it properly and start as I mean to go on.

by getting help with the basic coding. :evil:

 

outside of the email templates, I don't believe that $whmcs_admin_url exists in its own right - the best that you can do is recreate it from it's component parts...

 

global $CONFIG, $customadminpath;

"ticket_link" => $CONFIG['SystemURL'].'/'.$customadminpath.'/supporttickets.php?action=view&id='.$vars['ticketid'];

i'm assuming you have access to ticketid in the hook, but that might depend on which one you're using - otherwise, it may need to looked up.

 

I look forward to receiving a share of the profits. :idea:

Link to comment
Share on other sites

  • 2 weeks later...

I just did it in the email template instead DOH!!! that was the obvious solution.

 

 

aaah I took from the first line that this was for personal use and therefore couldn't understand why you had ignored the obvious solution... now it makes sense! :)

 

 

by getting help with the basic coding. :evil:

 

outside of the email templates, I don't believe that $whmcs_admin_url exists in its own right - the best that you can do is recreate it from it's component parts...

 

global $CONFIG, $customadminpath;

"ticket_link" => $CONFIG['SystemURL'].'/'.$customadminpath.'/supporttickets.php?action=view&id='.$vars['ticketid'];

i'm assuming you have access to ticketid in the hook, but that might depend on which one you're using - otherwise, it may need to looked up.

 

I look forward to receiving a share of the profits. :idea:

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