Jump to content

Auto Set Custom Field


mdwebhosting

Recommended Posts

Hi Guys,

 

I have a custom field for BPay reference and I need to set the value of this custom field automatically when an account is created. I've tried to find any helps in the forum without any success. Please advise. Thanks.

 

You could do this with ActionHooks.

When a client is created assign them a reference.

Link to comment
Share on other sites

Hi Shaun,

 

I've tried to do this in the actionhooks.php without any success. Please advise. Below is the code that I used.

 

function actionhook_ClientSignup($vars) {

# This function runs when a new client is added

# $vars["ClientID"]

# $vars["FirstName"]

# $vars["LastName"]

# $vars["CompanyName"]

# $vars["Email"]

# $vars["Address1"]

# $vars["Address2"]

# $vars["City"]

# $vars["State"]

# $vars["Postcode"]

# $vars["Country"]

# $vars["PhoneNumber"]

# $vars["Password"]

 

$uid = $vars['ClientID'];

 

$total = 0;

$even = 1;

 

while ($uid > 0) {

$val = ($uid % 10) * (++$even%2? 1 : 2);

if ($val > 10)

$val = ((int)($val / 10)) + $val % 10;

if ($val == 10)

$val = 1;

$total += $val;

$uid /= 10;

}

 

$ret = 10 - ($total % 10);

 

if ($ret >= 10)

$ret = 0;

 

$bpayid = $uid . $ret;

 

$sql = new mysqli('localhost', 'mdwh_scripte', 'nfX4wsT6j', 'mdwh_myacc');

$sql->query('INSERT INTO tblcustomfieldsvalues VALUES (3, $uid, $bpayid)');

}

Link to comment
Share on other sites

  • 1 year later...
Hi Shaun,

I've tried to do this in the actionhooks.php without any success. Please advise. Below is the code that I used.

Hi mdwebhosting & Shaun I also spent time trying to get this to work.

I seems that the Action Hook is called BEFORE any records are created in the DB thus there is no way of Updating them.

 

MATT is there a Action Hook that can be called on "Client Creation" but after all information is stored/created in the DB or a way of doing this in the current action hook?

Edited by ABetterDealForAll
Link to comment
Share on other sites

  • 2 years later...

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