Jump to content

Redirect client to new custom page after login to client area


Rahat_Arif

Recommended Posts

Hi, 

It is my goal to create a hook that, when a new client clicks on the Complete Order button after first ordering, the client is forced to log into the client area and then redirected to my custom page without first seeing the homepage. Please note: This is only for new clients

Thanks in advance

Link to comment
Share on other sites

  • 2 weeks later...

Try this one 

<?php
use WHMCS\User\Client;

add_hook('ClientAreaPage', 1, function($vars) {
    if (Client::isLoggedIn()) {
        $userId = (int) Client::getClientID();
        $clientDetails = Capsule::table('tblclients')
            ->where('id', $userId)
            ->first();
        $isFirstOrder = ($clientDetails->orders == 1);
        if ($isFirstOrder) {
            header("Location: https://yourdomain.com/custom-page-url");
            exit;
        }
    }
});

 

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