Create php code on custom field

More
11 years 6 months ago #49322 by Luca
Create php code on custom field was created by Luca
hi
i've a question:
it's possible insert a custom field where generate an personal code (written in php)?

thanks for answer

Please Log in or Create an account to join the conversation.

  • Tuan Pham Ngoc
  • Away
  • Administrator
  • Administrator
More
11 years 6 months ago #49327 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Create php code on custom field
Hi Luca

Unfortunately, the extension doesn't have any custom field which supports this feature.

Tuan

Please Log in or Create an account to join the conversation.

More
11 years 6 months ago #49339 by Luca
Replied by Luca on topic Create php code on custom field
Ok but i want know where (if i can) I can writing my personal code after i've created custom field...

Please Log in or Create an account to join the conversation.

  • Tuan Pham Ngoc
  • Away
  • Administrator
  • Administrator
More
11 years 6 months ago #49357 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Create php code on custom field
Hi Luca

It is very difficult for me to guide you without understand what you are trying to do. Could you please give me a detailed explanation about what you are trying to do so that I can think about it to see whether it is possible and then guide you?

Tuan

Please Log in or Create an account to join the conversation.

More
11 years 6 months ago - 11 years 6 months ago #49368 by Luca
Replied by Luca on topic Create php code on custom field
My intention is generate unique code in a custom field (CODE) with PHP:

<?php

$valore = makeUnique();


function makeUnique ($length=6)
{
$salt = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$len = strlen($salt);
$makepass = '';
mt_srand(10000000*(double)microtime());
for ($i = 0; $i < $length; $i++) {
$makepass .= $salt[mt_rand(0,$len - 1)];
}
return $makepass;
}
?>

Variable "$valore" print into custom field, send into a mail and save it into database.

I hope you understood the problem.

this help me in the next steps when people pay in bank. with this system i'll make in my site an automatic ceck for payment
Luca.
Last edit: 11 years 6 months ago by Luca.

Please Log in or Create an account to join the conversation.

  • Tuan Pham Ngoc
  • Away
  • Administrator
  • Administrator
More
11 years 6 months ago #49369 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Create php code on custom field
Hi Luca

I think in this case, you should not use custom field. This custom field is not available in the extension and you could not do that.

I think you can use the solution below:

1. Alter the #__eb_registrants table, add a new field called unique_code for example (you can name it in the way you want).

2. Customize the function in Register model in Events Booking so that when the registration record is being saved, you generate the unique code and save it into database as well

3. Customize the sendEmails function to send that data to the registrants as well

I know it contains several modifications but it is do-able.

Tuan

Please Log in or Create an account to join the conversation.

  • Tuan Pham Ngoc
  • Away
  • Administrator
  • Administrator
More
11 years 6 months ago #49370 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Create php code on custom field
Also, in #__eb_registrants table, there is an unique field called transaction_id already. it is unique for each registrant. So maybe you can use that field ?

Regards,

Tuan

Please Log in or Create an account to join the conversation.

More
11 years 6 months ago #49372 by Luca
Replied by Luca on topic Create php code on custom field
Good idea!
The transaction_id in #__eb_registrants table is perfect...

Now where I can make changes?

Thanks!

Please Log in or Create an account to join the conversation.

More
11 years 6 months ago #49402 by Luca
Replied by Luca on topic Create php code on custom field
How i can inserte the transaction_id in a automatic mail when people sign up for an event?

Please Log in or Create an account to join the conversation.

  • Tuan Pham Ngoc
  • Away
  • Administrator
  • Administrator
More
11 years 6 months ago #49403 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Create php code on custom field
It should be in the email message by default if you are using latest version. Maybe you can use [TRANSACTION_ID] tag in the email message.

I am not sure what version you are using, so I could not give you an exactly answer.

Regards,

Tuan

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc