gamestuff Posted April 29, 2014 Share Posted April 29, 2014 I am in the process of trimming down the required information for clients to register and would like to move to only being known by email. I have managed to set almost everything as needed, however I find when the "First Name" is blank, it causes issues linking back to clients through tickets as the text simply does not exist. To combat this I set a hidden field: <input type="hidden" name="firstname" id="firstname" value="Client"/> However this names everyone client, which is not ideal. I have tried using the email variable such as this, however it did not work: <input type="hidden" name="firstname" id="firstname" value="{$clientemail}"/> Does anyone know an easy way to push the "{$clientemail}" variable as the first name upon registration. Maybe I am simply missing something that I am overlooking. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted April 29, 2014 Share Posted April 29, 2014 one question: do you need it in admin area only? if in both admin and client area what about invoices? so you need the client email to be saved in firstname too? 0 Quote Link to comment Share on other sites More sharing options...
gamestuff Posted April 29, 2014 Author Share Posted April 29, 2014 Invoices need some tweaking but will only show Email address and no names. Yes, I would like to be able to save the email as both email and firstname at the time of client creation. 1 Quote Link to comment Share on other sites More sharing options...
sentq Posted April 30, 2014 Share Posted April 30, 2014 if that is what you need so create a new php file we will name it "emailasfirstname.php", and put the following code inside it: <?php function hook_addEmailAsFirstName($vars){ $userid = $vars['userid'];$email = $vars['email']; # Update Client FirstNamefull_query("UPDATE `tblclients` SET `firstname`='{$email}' WHERE `id`='{$userid}'");}add_hook("ClientAdd", 1, "hook_addEmailAsFirstName");?> then upload it to "WHMCS-Path/includes/hooks/" directory and we are done. this Hook will be called when client is registered from admin or client area and save his email as his first name, give a try - - - Updated - - - sorry unable to update my last reply, your code is here: <?php function hook_addEmailAsFirstName($vars){ $userid = $vars['userid']; $email = $vars['email']; # Update Client FirstName $updateclient = full_query("UPDATE `tblclients` SET `firstname`='{$email}' WHERE `id`='{$userid}'"); } add_hook("ClientAdd", 1, "hook_addEmailAsFirstName"); ?> 0 Quote Link to comment Share on other sites More sharing options...
gamestuff Posted April 30, 2014 Author Share Posted April 30, 2014 Thanks, this works great. I actually toyed with this a bit but then thought it might be able to be done through the form template. This does indeed work great though. Thanks! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.