froot Posted September 23, 2024 Share Posted September 23, 2024 if($user->isLoggedin() && !$input->get('profile') && !$input->get('logout')) { echo '<h2>'.__('Mein Profil').'</h2>'; echo '<p><strong>'.$user->fields[130].': </strong>' . '<span>'.$user->givenname.'</span></p>'; echo '<p><strong>'.$user->fields[131].': </strong>' . '<span>'.$user->lastname.'</span></p>'; echo '<p><strong>'.$user->fields[92].': </strong>' . '<span>'.$user->email.'</span></p>'; echo '<p><strong>'.$user->fields[171].': </strong>' . '<span>'.$user->units_balance.'</span></p>'; } I don't know why none of the values don't return anything (in the span tags). Also, the ->fields[] API is not very elegant either. Link to comment Share on other sites More sharing options...
da² Posted September 24, 2024 Share Posted September 24, 2024 (edited) It's hard to say what is your problem because $user->givenname should work if the template "user" has a field givenname with a value. So the problem is not this code, it's elsewhere. 17 hours ago, froot said: Also, the ->fields[] API is not very elegant either. You shouldn't need this, I didn't even know it exists and I added 27 fields on the "user" template in my current project. 🙂 Where does $user variable comes from in your code? Does the "user" template have all the properties? What var_dump($user) returns? Edited September 24, 2024 by da² 1 Link to comment Share on other sites More sharing options...
froot Posted September 24, 2024 Author Share Posted September 24, 2024 $user is the native user https://processwire.com/api/ref/user/ Isn't that what this module interacts with? Also, I'm actually using PageClass on the user class, i.e. class UserPage extends User { … } not sure if that's the culprit. I can apparently access the fields on a UserPage object just fine however. Link to comment Share on other sites More sharing options...
froot Posted September 26, 2024 Author Share Posted September 26, 2024 oh my, it was just a human error, I mixed up the logged-in accounts 🙈 Maybe I need to retire… or just need a vacation 😃 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now