Skip Navigation

[Resolved] Only one headline when calling site users

This support ticket is created 5 years, 4 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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 5 replies, has 2 voices.

Last updated by jesperK 5 years, 4 months ago.

Assisted by: Nigel.

Author
Posts
#1354953

Tell us what you are trying to do?

I need a list with users on the site divided into a list with departments as headlines. Like this:

----->
GENERAL STAFF
Jane Doe
John Bilkrav

SOME OTHER DEPARTMENT
Ben Oliver
Elsa Star

THE LAST DEPARTMENT
Cole Ridencen
Sam Ghin
----->

Is there any documentation that you are following?
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

This is my code:

[wpv-conditional if="( '[types usermeta='department']' eq '1' )"]
<h2>GENERAL STAFF</h2>
[wpv-user field="user_firstname"]
[/wpv-conditional]

[wpv-conditional if="( '[types usermeta='department']' eq '2' )"]
<h2>SOME OTHER DEPARTMENT</h2>
[wpv-user field="user_firstname"]
[/wpv-conditional]

[wpv-conditional if="( '[types usermeta='department']' eq '3' )"]
<h2>THE LAST DEPARTMENT</h2>
[wpv-user field="user_firstname"]
[/wpv-conditional]

But the result is like:
----->
GENERAL STAFF
Jane Doe
GENERAL STAFF
John Bilkrav

SOME OTHER DEPARTMENT
Ben Oliver
SOME OTHER DEPARTMENT
Elsa Star

THE LAST DEPARTMENT
Cole Ridencen
THE LAST DEPARTMENT
Sam Ghin

----->

Which is perfectly logical but wrong for my use 🙂

#1355089

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Jesper

You need to create separate queries for each.

You can make just one View and re-cycle it.

So create a View to display users. Add a Query Filter for the department custom field, and specify that the value should come from a shortcode attribute (give the attribute a name, maybe "department").

Out the user name and whatever else you require from each user.

Then where you want such a list to appear, insert the View as many times as needed, e.g.

<h2>General Staff</h2>
[wpv-view name="user-list" deparment="1"]
<h2>Some other department</h2>
[wpv-view name="user-list" deparment="2"]
...etc...

See https://toolset.com/documentation/user-guides/passing-arguments-to-views/

#1355467
Skærmbillede 2019-10-04 09.29.34.png
Skærmbillede 2019-10-04 09.27.39.png

Thanx Nigel 🙂
So far so good.
1.
I have made the custom user field 'Department'.
2.
And made the two views. 'Department'-view which is calling the 'Department child'-view with all the details need to show.

But I cannot get my head around the filter part...

There is no query filter option for the 'Department'-field?

Also I guess that it would be the 'user filer'-option I should use?

But who does the interaction work between the two views and who is the query specified to select the value from the custom field?

#1355557

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2019-10-04 at 09.34.57.png

Hi Jesper

You should only make one View, not two, and then you can re-use this one View as many times as you need, specifying the department each time you insert the View.

There seems to be a problem, though, in that the user field you created, I don't see it in the dropdown for the Query Filter for the View.

In my screenshot you can see that I created a User Field Group "Profile fields" which has one custom field, "Favourite team".

I can't see a Department field in your screenshot of the same dropdown.

Can you check again?

If you added a User Field Group at Toolset > Custom Fields then you should see the fields from that group listed in the Query Filter dropdown.

Are you using the latest plugin versions?

#1355599
Skærmbillede 2019-10-04 11.25.21.png

Now I got it to work! Thank you for all your help 🙂

It was a mystery why the custom field did not show up. Maybe some sort bug in rare cases made it not work properly?
I delete it and made a new one with the same name and that showed up...

Limited the view down to one and inserted the shortcode attribute department="".

Like this:
<h2>REDAKTION CAP&DESIGN</h2>
[wpv-view name="departments-contact-page" department="1"]

<h2>SÄLJ/EKONOMI</h2>
[wpv-view name="departments-contact-page" department="2"]

<h2>ARATELJÉ/PRODUKTION</h2>
[wpv-view name="departments-contact-page" department="3"]

#1355613

My issue is resolved now. Thank you!