Jump to content

I need to assign a default value to the postal code when they register


Recommended Posts

Hello, to put them in context.

Recently, the postal codes of Peru changed the format, so when a person buys a domain (which is configured to do autosetup with resellerclub) and puts the format of the previous zip code and makes the payment, this automatic configuration of the domain does not proceed and shows an invalid postcode error.

With which I am having many orders trapped by this detail ... then I am trying to assign a valid default zip code to resellerclub so that I can do the automatic configuration of the domain when an order is placed and the customer registers.

Unfortunately, most people still do not know the new format of the postal codes of Peru, so this solution is more than necessary and I would greatly appreciate your technical support.

I have seen the developer documentation and I am using the "ClientAdd" hook to try to modify the value of the zip code field for one that is valid ... but I have not succeeded.

I leave a screenshot attached to view my code and I can guide myself to achieve this, since I am leaving many automatic configurations of domains stuck in the process.

I do not want to validate the postal code field so I do not use the hook "ClientDetailsValidation" .. but I want to assign a specific value for all the records that are from Peru .. whatever the value that the client inserts in the code postal at the time of registration I want to change the value of the postal code for a valid one and that this is sent to the autosetup of the domain.

Thank you!! I remain attentive to your prompt response.

Screenshot_6.png

Link to comment
Share on other sites

all of the following actionhook points (ClientAdd, ClientEdit, and ClientDetailsValidation) doesn't support response/modification of the information entered by the client, so what you need to do here is to update clients record in database directly

<?php

use WHMCS\Database\Capsule;

add_hook("ClientAdd", 1, function($vars){

  if ($vars['country'] == "PE"){
    Capsule::table("tblclients")
      ->where("id", $vars['userid'])
      ->update(array("postcode" => "15026"));
  }

});

this would work exactly as you want

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • 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