Joomla 5 Notice

We are pleased to announce that as of January 29, 2024, all of our Joomla extensions are compatible with Joomla 5.

For all who are still updateing from Joomla 3 to Joomla 4: Joomla 4 Migration instructions are available here:

There is now a separate Documentation for Visforms for Joomla 4 and for Visforms for Joomla 5!

Forum

Visforms Subscription user can ask questions in our forum. Please log in with the relevant user first.
Everybody can access the forum for reading.

Please only ask 1 question per topic.

Important information for almost every question:
V1: Which Visforms version is running?
V2: Which Joomla version is running?
V3: Which PHP version is running?

Access to logged on user's data

More
9 years 4 weeks ago - 9 years 4 weeks ago #2151 by robinhair
Access to logged on user's data was created by robinhair
I downloaded VisForms and got it working well. Congratulation on a very useful and well documented Joomla extension!

I've created an input form which is only accessible to logged on users. VisForms lets me access their Name, Username, and Email Address, but I'd like to access other 'standard' information contained in their user data. Is there anyway to do this in the latest version (I have the Beta version installed)?

Thanks
Robin
Last edit: 9 years 4 weeks ago by robinhair. Reason: Typos!

More
9 years 4 weeks ago #2153 by Administrator AV
Replied by Administrator AV on topic Access to logged on user's data
Hi Robin,

thanks, you're welcome.

Sorry, but even in the current latest beta only username, name and user email address are accessible.
Which other fields would you define as "standard" information?

Regards,
Aicha

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).

More
9 years 4 weeks ago #2158 by robinhair
Replied by robinhair on topic Access to logged on user's data
Hi Aicha,

Thanks for your prompt reply. When I said 'standard', I was thinking about the fields that can be included in the Joomla User Registration page, and might therefore be available in the same way as Name, Username and Email. Specifically my intended use concerns the delivery of auction goods, so I was after extracting the user's Postal Address and Telephone Number.

Thanks
Robin

More
9 years 4 weeks ago #2160 by Administrator AV
Replied by Administrator AV on topic Access to logged on user's data
Hi Robin,

ok, you are talking about the field of the user profile. (Added through user profile plugin).
I can set this on my todo list.
But I don't know, when I will be able to implement it.

Regards,
Aicha

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).

More
9 years 4 weeks ago #2162 by robinhair
Replied by robinhair on topic Access to logged on user's data
Hi Aicha,

Understood about adding to your todo list, thanks. In the meantime I found the following on the internet and wonder if I could insert this code somewhere to achieve the same effect as the Name/email. I'm afraid I wouldn't have a clue where such code would have to go within VisForms, but am happy to try something out if you would kindly supply detailed instructions as to exactly which file and where it should be located.

The extract came from:
joomla.stackexchange.com/questions/899/h...-profile-information

To access the User Profile Data:

jimport( 'joomla.user.helper' );
$user = JFactory::getUser();
$userId = $user->id;
$userProfile = JUserHelper::getProfile( $userId );

echo "Main Address :" . $userProfile->profile;

Would there be some way to pre-fill the address box with address1, address2 etc using the above method?

Many thanks
Robin

More
9 years 4 weeks ago #2163 by Administrator AV
Replied by Administrator AV on topic Access to logged on user's data
Hi Robin,

this is the code to get the profile information from the database. This in only one step in the right direction.
You have to change at least the following two Visforms core files
adminstrator/components/com_visforms/models/forms/visfield.xml
components/com_visforms/lib/field/text.php

In the xml file you have to add an Option for each profile information you want to use in the xml node "field" with the name attribute "f_text_fillwith".
Code:
<field name="f_text_fillwith" type="list" label="COM_VISFORMS_FILL_FIELD_WITH" description="COM_VISFORMS_FILL_FIELD_WITH_DESC" class="inputbox" default="0"> <option value="0">COM_VISFORMS_INITIAL_VALUE</option> <option value="1">COM_VISFORMS_CONNECTED_USER_NAME</option> <option value="2">COM_VISFORMS_CONNECTED_USER_USERNAME</option> </field>

Like
Code:
<option value="3">Addr1</option>

In the php file you have to adapt the function setFieldDefaultValue()
Basically you have to add a new if statement in the following part of the code for each option which you have added to the xml file.
Code:
if ((isset($field->fillwith) && $field->fillwith != "")) { $user = JFactory::getUser(); $userId = $user->get('id'); if($userId != 0) { if($field->fillwith == 1) { $this->field->attribute_value = $user->get('name'); return; } if($field->fillwith == 2) { $this->field->attribute_value = $user->get('username'); return; } } }

Like
Code:
if($field->fillwith == 3) { //get addr1 from profile return; }
I think this should do the trick, but this is absolutely untested and without any guarantee.

Regards,
Aicha

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).

Moderators: Administrator AVAdministrator IV
Powered by Kunena Forum