Jump to content

Using localAPI and AddOrder + AddClient from server module ClientArea-callback


sith

Recommended Posts

Hi!

I'm trying to use the localAPI with the AddOrder and AddClient commands from within a module ClientArea-function. Everything works fine except that the current session is changed. This means that if a client logs in normally to the client area, the next request after the request that triggers the localAPI call will result in a logout and a redirect to the login page. If the same is done as an admin using the "login as client" button, it results in a redirect to the client the order was added for or the new client.

According to WHMCS support, you're not supposed to call AddOrder and AddClient from this context. And since this is not intended functionality they suggested that I ask here.

Does anyone have any idea about a workaround? I'm thinking that I could restore the client area session with a hook. What data do I need to store to be able to do that?

I guess I could implement this AddOrder/AddClient by editing the database directly, however I really want to avoid this. Implementing a work queue that is executed in another context would also be an option, however, I'm not really sure about from which contexts I'm actually allowed to call AddOrder and AddClient, it seems like this is not documented.

Link to comment
Share on other sites

30 minutes ago, string said:

Maybe you could just save the $_SESSION variable before the hooks and then restore it.

It worked! I hope that it didn't break something else.

And it was unnecessary to restore from within a hook. I just restored before returning from the ClientArea callback.

Thanks for pointing me in the right direction!

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