Skip Navigation

[Resolved] How do I display a single WP user profile from a directory of user profiles?

This support ticket is created 4 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 9 replies, has 2 voices.

Last updated by jeffS-2 4 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#1506219

Tell us what you are trying to do?
I have a brand new directory site in which I created a directory page, listing WP user profiles. It displays only a few fields from each profile (name, email, phone.) A link at the bottom of each displayed profile should open and display the full profile (based on a content_template single.) I can't figure out how to make that link work so it displays THIS profile using the content_template single.
I think I need to use the WP User ID, but not sure how to get that into the shortcode properly.

Is there a similar example that we can see?
Sort of. I have done this for a different site, but it uses a CPT not a user_profile, so I use [wpv-post-url] but of course that won't work for a User. - See the working CPT site here:
hidden link

What is the link to your site?
Site is currently on Local only: hidden link

Jeff
–––––

#1506485

Hello,

You can try these:
1) Create a user view:
- Query Users
- Filter by:
Select users with the id determined by the URL parameter "users-filter" and with role "(any)"
eg. yoursite/page-with-this-view/?users-filter=1
- In view's loop, display user's information

2) Create a page "full profile"(for example, page ID is 123), display above user view

3) Edit your "directory page", setup HTML link to above page, pass user's ID as URL parameter, for example:
link to user full profile page

If you are using user view in the "directory page", you can replace 456 with view's shortcode [wpv-user field="ID"].

More help:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-user
Display user info. If the shortcode is inside a Views user query, it will display information for the user found in loop.

#1508189

Thanks, Luo.
Almost there.

It sort of works - it does display using the correct content template and looks nice.
However, it is always displaying the user ID=1, no matter which one I click in the directory. If you hover on the "View profile" link for each one in the directory, it appears to be building the URL correctly (user-ids=2, 3, etc.)

So, I suspect the user ID part is not working, and so the View is defaulting to current-user (ID=1 is my admin account.) I noticed if I am logged out, the WP usermeta fields display as blank.

Also, I just now turned on Views DEBUG, and it does not popup on the member-profile-single view, but it does popup on the directory view. I cannot understand that, even after looking at the member-profile-single view over and over. It seems straightforward.

Site at: hidden link

Jeff
–––––––

#1508263

Please check the document I mentioned above:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-user

The shortcode [wpv-user field="ID"] works as below:
- If it is in user view's loop, it will output current user's ID
- Otherwise it will display the current logged-in user's ID

How do you setup the "directory page", if it is using custom PHP codes/other plugins, not using user view, you will need to setup custom PHP codes to get the user's ID.

#1514021
Member Profile Full view.png
Directory View.png

Sorry Luo -
There must be something I am missing, or I am not understanding how it works. I thought it seemed straightforward. So, here they are. I am not using any PHP code for this.

The page "patel-directory" uses the view, "member-profile-short", which is a user view, any role, order by User registered date, no limit, no filter and no pagination. In the loop, I have only one line: [wpv-post-body view_template="member-profile-short"]

The "member-profile-short" template grabs a user profile, and displays user_firstname, user_lastname, user_email, user_biographical_info, and wpcf-user-phone (Types user field).

That all works correctly.

At the bottom of that "member-profile-short" template, I have the link:
View Profile  
Hovering on that link correctly shows the ID of each profile (1, 2, 3, etc.): /member-profile?users-filter=2
'58' is the post_id of the Page, "member-profile" which calls [wpv-view name="member-profile-full"].

The view, "member-profile-full" is a user view, any role, order by User registered date, limit 1 item, filter =
Select users with the id determined by the URL parameter "users-filter" and with role "(any)"
eg. yoursite/page-with-this-view/?users-filter=1
No pagination.
The loop has only one line: [wpv-post-url view_template="member-profile-full"]

The "member-profile-full" template grams the same user fields as the "short" template, except it displays the "wpcf-full-bio-description"(Types user field) instead of user_biographical_info field.

I think I am following the instructions in the documentation you linked for me above, but I must have something wrong somewhere if I am always getting the Current user's info only.

Does it look like I have the above views set correctly?

Also, a clue might be that if I enable Views Debug, I get the Debug popup for the first (Directory) view, but when I click on my "View Profile" link, it opens the member-profile-full template without poping up the Debug info. I can't figure out why this happens.

Thanks for any clues you might have.
Jeff
–––––––

#1514093

Please provide a test site with the same problem, also point out the problem page URL and view URL, I need a live website to test and debug. thanks

#1515647

Thanks for the details, I have done below modifications in your website:
1) Create a new page "Member Profile 2": ID 88
hidden link
display user view's shortcode directly:
[wpv-view name="Member Profile Full"]

2) Edit the user view "Member Profile Full":
hidden link
option "Limit and Offset", choose "Unlimited", so Views will output all results by default.

in section "Loop Editor", change the shortcode from:
[wpv-post-url view_template="member-profile-full"]
To:
[wpv-post-body view_template="member-profile-full"]
Here you are using wrong content template shortcode, it should be [wpv-post-body]:
hidden link

In section "Member Profile Full", display the HTML link directly:

<a href="[wpv-post-url item='88']?users-filter=[wpv-user field='ID']"> View Profile </a>

Test it in front-end:
hidden link
It works fine, can you confirm it?

#1515657

Luo -

Thanks for your efforts. However, the result of these changes do not make sense to me. Now I see both views display all member profiles. The first view shows short description, and the second view shows full descriptions.

The way it is supposed to work:
Patel Directory page calls Member-Profile-Short view to display the short version of each member profile. Then, you click on the "View Profile" link in any short profile in the Directory page, and it should open the Full version of the profile that was clicked on in the Directory page.

If this does not make sense to you, I can close this issue and redo my site in another platform. It is a very simple website project. I have been using Types/Views for more than 5 years on other sites but only with CPTs not for User. I was hoping I could make it work quickly with Toolset.

Thanks,
Jeff
–––––––

#1515711

In the private message box:
https://toolset.com/forums/topic/how-do-i-display-a-single-wp-user-profile-from-a-directory-of-user-profiles/#post-1515537
You only mentioned one view and one page, so I thought you just want to achieve it with one page and one view and provided the solution within one page and one view.

If you want to do it with two pages and two views, you just need to create another page and another view, for example:
1) Create a new user view "Member Profile single", with same setting as view "Member Profile Full", but limit one
2) Creat a page "single user profile"(for example ID 123), display above user view's shortcode
3) in user view "Member Profile Full", setup the link to above page:
View Profile

For your reference.

#1515783

There seems to be a big communication problem here. Luo has always been exceptional in helping me over the years with different sites. But, we just can't seem to get on the same page on this one.

This is a simple and quick WP User site, and I thought I would give the User side of Types/Views a try, since I've so far only made use of the CPTs. But, I have now spent too much time here, and need to move on, as my client is getting impatient.

Thanks,
Jeff
–––––––