WebSite X5Help Center

 
Vagn M.
Vagn M.
User

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

Autore: Vagn M.
Visite 247, Followers 1, Condiviso 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

Postato il
19 RISPOSTE
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

Leggi di più
Postato il da Axel  
Vagn M.
Vagn M.
User
Autore

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

Leggi di più
Postato il da Vagn M.
Axel  
Axel  
User

By CSS I suppose.

Hey KolAsim, can you help us ?

Axel

Leggi di più
Postato il da 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

.

Leggi di più
Postato il da  ‪ KolAsim ‪ ‪
 ‪ KolAsim ‪ ‪
 ‪ KolAsim ‪ ‪
Moderator

...incorrect password...

.

Leggi di più
Postato il da  ‪ KolAsim ‪ ‪
Axel  
Axel  
User

it works fine from my side... check again

Leggi di più
Postato il da Axel  
Vagn M.
Vagn M.
User
Autore

I succeede on my first login, but now I get this message:

Best Regards
Vagn

Leggi di più
Postato il da Vagn M.
Axel  
Axel  
User

go to myaccount page and force a logout

check again

Leggi di più
Postato il da Axel  
Vagn M.
Vagn M.
User
Autore

Now I got access again.

I entered some information and send it.

But I can't see the result.

And I am also just a little confused about what to do to build the same functionality up here in Denmark.

Best Regards
Vagn

Leggi di più
Postato il da Vagn M.
Axel  
Axel  
User

Hey Vagn

my page does not work to populate the field

so we are waiting KooAsim´help to do it

axel

Leggi di più
Postato il da Axel  
John S.
John S.
User

Use ENTER on the keybord instead of clicking the button

Leggi di più
Postato il da John S.
Axel  
Axel  
User

I dont understand 

works on my phone too

here after authentication !!!!

Leggi di più
Postato il da Axel  
Axel  
Axel  
User

@John

it works from your side ?

Axel

Leggi di più
Postato il da Axel  
John S.
John S.
User

@Axel

No.

It does not work in Chrome or Firefox when I use the click-button.

When I use the button I get the same message as KolAsim.

But when I press ENTER it functions.

Leggi di più
Postato il da John S.
 ‪ KolAsim ‪ ‪
 ‪ KolAsim ‪ ‪
Moderator

... OK... after a few tries it worked, but it's not regular...
... it would be better if the email text was in a single object with just the email and not like it is now with other text...
... however, for the current situation you can use this code of mine with which I extracted the email, obtaining what you see in my STAMP:
<script>
/** -- assegna email automaticamente da utente loggato x WSx5 by KolAsim --- **/
$(document).ready(function () {//K>;
setTimeout(function () {//K1>;
str_emailK = $("#imHTMLObject_343_02").text();
var estraeEmailK = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
var emailEstrattaK = str_emailK.match(estraeEmailK);
if (emailEstrattaK) {//K2>;
$(".valEmail").val( emailEstrattaK[0]);
$(".valEmail").prop('disabled', true);
} ;//K2<<;
}, 3000);//K1<<; // ritardo 3000 (ms) = 3 (sec) da valutare --:
});//K<<;
</script>

.

ciao

.

Leggi di più
Postato il da  ‪ KolAsim ‪ ‪
Axel  
Axel  
User

@John,
OK, I have done a post regarding this issue.

@KolAsim
AGain, great job

You are right, should be easier to have each line into one text object to avoid extraction like you have done.

@Vagn
Now you have the KolAsim script to put automatically email into the field.. You just need to authentificate the field name by an inspect into your browser

Here the email field is #imHTMLObject_343_02

Like into inspect

Axel

Leggi di più
Postato il da Axel  
 ‪ KolAsim ‪ ‪
 ‪ KolAsim ‪ ‪
Moderator
Axel  
... ... ...  @KolAsim AGain, great job ... ... ... 

...I checked, ...OK...it works...

.

Leggi di più
Postato il da  ‪ KolAsim ‪ ‪