WebSite X5Help Center

 
Vagn M.
Vagn M.
User

How to add the logged in user to a contact form  en

Автор: Vagn M.
Просмотрено 151, Подписчики 1, Размещенный 0  

I am trying to figure out how I can add a username a logged in user to a contact form.

Is it possible or do I need to develop a contact form myself?

Best Regards
Vagn Majland

Размещено
6 Ответы
Axel  
Axel  
User

Hello Vagn,

Into your page add an HTML object and copy paste this code.

<?php
$pa = Configuration::getPrivateArea();
$user = $pa->whoIsLogged();
echo "Bienvenue : ".$user['realname'];
?>
<br> </br>

<?php
$pa = Configuration::getPrivateArea();
$user = $pa->whoIsLogged();
echo "Bienvenue : ".$user['username'];
?>
<br> </br>

<?php
$pa = Configuration::getPrivateArea();
$user = $pa->whoIsLogged();
echo "Bienvenue : ".$user['uid'];
?>

Here 3 different displaying

And VERY IMPORTANT. The page needs to be private for the user / group

And the result is:

Hope this helps

Axel

Читать больше
Размещено От Axel  
Vagn M.
Vagn M.
User
Автор

Hi Axel

Thank you for the prompt answer.

Unfortunately the answer does not solve our problem. We already have this code in the solution:

<?php
require_once"res/x5engine.php";
$pa = Configuration::getPrivateArea();
$user = $pa->whoIsLogged();

echo    "<script>";
echo    "localStorage.setItem('Fornavn', '".$user['firstname'] ."');";
echo    "localStorage.setItem('Efternavn', '".$user['lastname'] ."');";
echo    "localStorage.setItem('Email', '".$user['email'] ."');";
echo    "localStorage.setItem('Brugernavn', '".$user['username'] ."');";
echo    "localStorage.setItem('UID', '".$user['uid'] ."');";
?>

It is working very well and we can all over the site get, manage, show and print the information.

But how can we get teh information inserted into a field in the contact form? E.g. in the Name field where you see the arrow:

Best Regards
Vagn

Читать больше
Размещено От Vagn M.
Axel  
Axel  
User

By CSS I suppose.

Hey KolAsim, can you help us ?

Axel

Читать больше
Размещено От Axel  
 ‪ KolAsim ‪ ‪
 ‪ KolAsim ‪ ‪
Moderator
Axel  
... ... ...  Hey KolAsim, can you help us ?  ... ... ... 

... (It > En)

1) ... post the LINK to the relevant page with the contact form;
2) ... apply the EXTRA PHP code to detect the logged-in user visible on the page;
3) ... create a fully enabled dummy user "pippo" with:
- user: pippo(At).xx.yy ... (AT) = @
- pas: 12345
...
... if this is done and I see this, I'll come back here...

.

ciao

.

Читать больше
Размещено От  ‪ KolAsim ‪ ‪
Axel  
Axel  
User

Hey KolAsim

thank you for your help

demo is ready here

page: https://wsx5demo.afsoftware.fr/bb.php

login:  demo at  demo.com

pass: password

Axel

Читать больше
Размещено От Axel  
 ‪ KolAsim ‪ ‪
 ‪ KolAsim ‪ ‪
Moderator

...incorrect password...

.

Читать больше
Размещено От  ‪ KolAsim ‪ ‪