Jump to content

Custom User Fields


DaveP
 Share

Recommended Posts

Forgive me if this has been answered before, but the threads I have read have talked about upcoming features, which I am not sure whether they are available or not.

What I am trying to do is have quite a comprehensive user profile available (I am attempting to build a simple forum with PW). I can sort of get it to work with a second user profile table, but there is always the possibility that the two will get out of step.

Is there a way of adding fields to the existing 'users' pages? (Any other tips would be most welcome.)

Link to comment
Share on other sites

Dave,

You can add whatever fields you want to the user template. I'm building a fairly complex user profile setup as well.

Go to: Setup > Templates, at the top of the page open the "filters" area and enable "show system templates".

Now you can add any of your fields to the user template.

  • Like 3
Link to comment
Share on other sites

Supplementary question - what's the best way to have some information from a user profile available for public viewing (ie to allow 'guest' viewing rights to some information)?

Link to comment
Share on other sites

Hi Dave,

Unless there's some method of showing profile info that I'm not aware of (entirely possible), you can choose to display or not display any profile information in your template.

<h2><?=$user->name?></h2>
<p><?=$user->job_title?></p>
<p><?=$user->bio?></p>
<p><?=$user->email?></p>
Link to comment
Share on other sites

This comes back to everything in PW being a page, even users.

For example, I can fetch myself using $pete = $pages->find('template=user, name=pete, include=hidden');

You might want to check that field name though since I'm on my phone, but I think that's right anyway. Either way the users section is hidden so you will need that bit on the end I think.

Link to comment
Share on other sites

  • 4 years later...
<?php foreach($users->find($item->writer) as $usr); ?>

Odd thing that my custom field not showing when using print_r or var_dump, but still works if using $usr->customfield. Sorry about this post, I had a question, but found an answer already. Can't delete my own posts.

Link to comment
Share on other sites

  • 2 years later...

Hello,

I have created a standard field type as userphone , then I added this field to the User template. I created a phone field type using Phone Field module. I added this field to the User template also.

image.thumb.png.f40f3d23d3f8849fdf15e13a06ef63b6.png

Now I used the below to create a test user

 $u = new User();
$u->of(false);
$u->name = "saarun";
$u->email = "saarunthomas@example.com";
$u->pass = "123456";
$u->Phone = 9446196667;
$u->userphone = 9446196667;
$u->headline = "hello there";
$u->paid=1;
$u->addRole("registered");
$u->save();
$u->of(true);

and I tried to out put as below

     $item = $users->get("saarun");
echo $item->email;
echo $item->Phone;
echo $item->paid;
echo $item->headline;
echo $item->userphone;

and I got the output a below.  Neither the userphone value nor the Phone value are output ... what am I doing here wrong  ? pls help

 

image.png.eee59c5c952dd521d71cb1dd8d23cd22.png

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...