adding php in custom field Topic is solved

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Post Reply
Sly036
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sun Aug 25, 2019 1:40 pm

adding php in custom field

Post by Sly036 » Thu Sep 05, 2019 6:58 pm

Hi all :)

Is there any one can tell me if or how i can put this value in a custom field !

php i need to insert :

<?php
function GeraHash($qtd){
//Under the string $Caracteres you write all the characters you want to be used to randomly generate the code.
$Caracteres = 'ABCDEFGHIJKLMOPQRSTUVXWYZ0123456789';
$QuantidadeCaracteres = strlen($Caracteres);
$QuantidadeCaracteres--;

$Hash=NULL;
for($x=1;$x<=$qtd;$x++){
$Posicao = rand(0,$QuantidadeCaracteres);
$Hash .= substr($Caracteres,$Posicao,1);
}

return $Hash;
}

//Here you specify how many characters the returning string must have
echo GeraHash(7);
?>

I need it to be insert in USER DB on inscription.

Thank's in advance :D

harperlala
Joomla! Guru
Joomla! Guru
Posts: 672
Joined: Mon Aug 24, 2015 5:55 pm

Re: adding php in custom field

Post by harperlala » Fri Sep 06, 2019 4:24 am

that is one field of user? but when do you want to add it?
when user register done or user edit profile or.....?????

Sly036
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sun Aug 25, 2019 1:40 pm

Re: adding php in custom field

Post by Sly036 » Fri Sep 06, 2019 1:22 pm

Hi harperlala

yes just a one field on registration form "view only " created on registration.

showing up on profile not editable, under "code secret client" (that code should be unique)

harperlala
Joomla! Guru
Joomla! Guru
Posts: 672
Joined: Mon Aug 24, 2015 5:55 pm

Re: adding php in custom field

Post by harperlala » Fri Sep 06, 2019 4:15 pm

you talk that done before: viewtopic.php?f=708&t=973958

Sly036
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sun Aug 25, 2019 1:40 pm

Re: adding php in custom field

Post by Sly036 » Fri Sep 06, 2019 5:30 pm

Similar but not exactly the same,

i succeed with breezingforms pro creating that, the problem with breezing form is that i cant use it in the default joomla registration, contentbuilder does it but i cant add that kind of field. in the topic i talk before was to join parents and kids.

i dont know why its so hard to had a php code in custom field in joomla, is there a way or not ? it will be easier to work in a custom field then go miss up with .php file.

SharkyKZ
Joomla! Ace
Joomla! Ace
Posts: 1621
Joined: Fri Jul 05, 2013 10:35 am
Location: Unknown

Re: adding php in custom field

Post by SharkyKZ » Fri Sep 06, 2019 6:05 pm

Make your own plugin.

Sly036
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sun Aug 25, 2019 1:40 pm

Re: adding php in custom field

Post by Sly036 » Fri Sep 06, 2019 10:39 pm

Hi SharkyKZ

Get that kind of answer from a Joomla ace member ! i'm kind of shocked !

If i knew how to make plug-ins i'm quite shure i wouldn't need to come and ask that kind of question.

I thought Joomla community was based on helping each other's ! well it use to be !

i'm just starting a formation on php so i don't have the lvl yet but will get there. then i'm quite shure i'll be able to make my own plug-ins and be happy to share it with those people here like me that might need it.

I'm sorry for even asking help here. since 2007 i'm working with joomla but with your kind of answer i think it will end.

User avatar
sozzled
Joomla! Exemplar
Joomla! Exemplar
Posts: 7869
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia
Contact:

Re: adding php in custom field

Post by sozzled » Sat Sep 07, 2019 2:42 am

I looked at the documentation for custom fields: https://docs.joomla.org/J3.x:Adding_custom_fields

There are sixteen different field types. They are:
  1. Calendar Field
  2. Checkboxes Field
  3. Color Field
  4. Editor Field
  5. Integer Field
  6. List Field
  7. List of Images Field
  8. Media Field
  9. Radio Field
  10. Repeatable Field
  11. Sql Field
  12. Text Field
  13. Textarea Field
  14. Url Field
  15. User Field
  16. Usergroup Field
I do not see a field type for "PHP". So, I guess the answer to your original question is that you cannot do what you want to do with custom fields.

If this was my website, and I wanted to add some PHP value to the registration process, I would develop a system plugin using the OnContentPrepareForm trigger.
https://www.kuneze.com/blog
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?” :)

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 26017
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: adding php in custom field

Post by Per Yngve Berg » Sat Sep 07, 2019 9:08 am


SharkyKZ
Joomla! Ace
Joomla! Ace
Posts: 1621
Joined: Fri Jul 05, 2013 10:35 am
Location: Unknown

Re: adding php in custom field

Post by SharkyKZ » Sat Sep 07, 2019 9:35 am

Sly036 wrote:
Fri Sep 06, 2019 10:39 pm
Hi SharkyKZ

Get that kind of answer from a Joomla ace member ! i'm kind of shocked !

If i knew how to make plug-ins i'm quite shure i wouldn't need to come and ask that kind of question.

I thought Joomla community was based on helping each other's ! well it use to be !

i'm just starting a formation on php so i don't have the lvl yet but will get there. then i'm quite shure i'll be able to make my own plug-ins and be happy to share it with those people here like me that might need it.

I'm sorry for even asking help here. since 2007 i'm working with joomla but with your kind of answer i think it will end.
I am trying to help. I gave you a straight answer. Don't go placing PHP code in random places and in general do not modify core files. This has been said on the forum many times. A custom plugin is the way to go in such case.

Here's some documentation to get you started:

https://docs.joomla.org/Creating_a_profile_plugin
https://docs.joomla.org/J3.x:Creating_a ... for_Joomla
https://docs.joomla.org/J3.x:Creating_a_content_plugin
https://docs.joomla.org/Plugin/Events/User

Sly036
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sun Aug 25, 2019 1:40 pm

Re: adding php in custom field

Post by Sly036 » Fri Sep 13, 2019 6:07 pm

Hi all

sorry for late answer i was really busy with that site and that specific demand .
no problem SharkyKZ i understand and that day i just wanted to bang my head on the wall lol

i succeeded with breezingforms.

i have another situation thow ! regarding after activation, it redirect to joomla profile even if i have the redirection in the login module to another profile form, but works fine when log-in normaly.

i've been google-ing but all the answer to kinda fix that are 4 -5 years old and not good for 3.9.11

if you guy's have any clue or link to take care of that matter will be great !

Regards
Sly

Sly036
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sun Aug 25, 2019 1:40 pm

Re: adding php in custom field

Post by Sly036 » Fri Sep 13, 2019 6:57 pm

Sly036 wrote:
Fri Sep 13, 2019 6:07 pm
Hi all

sorry for late answer i was really busy with that site and that specific demand .
no problem SharkyKZ i understand and that day i just wanted to bang my head on the wall lol

i succeeded with breezingforms.

i have another situation thow ! regarding after activation, it redirect to joomla profile even if i have the redirection in the login module to another profile form, but works fine when log-in normaly.

i've been google-ing but all the answer to kinda fix that are 4 -5 years old and not good for 3.9.11

if you guy's have any clue or link to take care of that matter will be great !

Regards
Sly

Héhé got it :p i didn't want to play in the core so i just went on cpanel and redirect joomla profile directly to the good profile, if it can help other's that's cool :D

Regards
Sly


Post Reply

Return to “General Questions/New to Joomla! 3.x”