Skip Navigation

[Resolved] Table of users and CPTs

This support ticket is created 6 years, 5 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
- 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 16 replies, has 2 voices.

Last updated by Kostas 6 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#590000

Hello,

I am planning to implement the following table:

Y (vertical) axis: all wp users, members a custom role
X (horizontal) axis: all posts of a custom post type

Coordinates are checks (ticks), if a certain user has created a child post of the corresponding post on the X axis, or not.

So, we should see which users have created child posts of which parents, and which users have not.

Is that possible with Views? If so, please send some guidelines, on how I could build the table structure. I am okay with the actual code, I just do not know how I can setup a view to implement it.

Thanks in advance,
Kostas

#590111

Dear Kostas,

Thanks for the details, I think it is possible within a three levels view, for example:
1) Grandparent view list all posts, display below parent view, and pass post ID as the attribute of shortcode [wpv-view],
for example: [wpv-view name="parent-view" mypostid="[wpv-post-id]"]
one post one table row.
https://toolset.com/documentation/user-guides/passing-arguments-to-views/
section "Controlling the filter with shortcode attributes"

2) Parent view list all users, display below child view, and pass one parameter as attribute of shortcode [wpv-view], for example:
[wpv-view name="child-view" mypostid="[wpv-attribute name="mypostid"]"]
Each user display as one table grid.

3) Child view list child posts, filter by two filters:
a) Post author filter
Select posts with the author set by the parent User View.
https://toolset.com/documentation/user-guides/filtering-views-query-by-author/?
b)Post relationship filter
Select posts that are children of the Post with ID set by the shortcode attribute mypostid.
eg. [wpv-view name="view-name" mypostid="123"]
wp-types.com/documentation/user-guides/querying-and-displaying-child-posts/

#591089

Hi Luo,

Thanks for your response. I am afraid I find it hard to follow you.
Can you please elaborate a bit?

Thank you,
Kostas

#591130

I have already provide detail steps in above answer:
https://toolset.com/forums/topic/table-of-users-and-cpts/#post-590111
I am not sure which step you need to be elaborated.

If you still need assistance for it, please provide a test site with same problem, I can setup a demo for you.

#593298

Hi Luo,

Please enable private posting.

Thanks,
Kostas

#593322

The private message box has been enabled, please provide the credentials, also point out the problem page URLs. thanks

#593696

Here is the example in your test site:
1) three views:
a)Grandparent view list all posts
hidden link
b) Parent view list all users
hidden link
c) Child view list child posts
hidden link

Put the grandparent view into a page:
hidden link

It is only an example, you will need to customize the HTML structure into a HTML table

#594871
table-of-users-and-cpts.png

Hi Luo,

Thanks a lot for providing the example.
However it does not seem to suit my needs. I am trying to build something like the attached image.
For example, if user1 has created a child (answer) of 1A (sample), then a check is printed, etc.
In your example, users are printed multiple times, which I do not need.
Do you think it's possible to build a table like the attached image, with Toolset??

Thanks again,
Kostas

#594932

For the question:
Do you think it's possible to build a table like the attached image, with Toolset??

Yes, it is possible to build such a table like the attached image, As I mentioned above, you will need to customize the HTML codes structure into a HTML table, here is a document about HTML table:
hidden link

Please let me know if you still need assistance to setup the HTML codes.

#594951

Yes, any help to setup the HTML codes will be appreciated.

Thanks!

#595512

As your request, I am trying to setup table HTML codes for you, but your test site is very slow in my side, so I am export the database dump file from your website to my localhost, will feedback if there is anything found

#595519

I just setup a demo in your website, see the result page:
hidden link

Here are details steps:
1) Add below PHP codes into your theme/functions.php:

add_shortcode('hide-it', 'hide_it_func');
function hide_it_func(){
    return;
}

Views shortcode [wpv-layout-start] ... [wpv-layout-end] will output an extra HTML div tag, we use shortcode [hide-it] to hide the HTML div tag. We will need to apply it to all below views.

2) Grand parent view, list all Taster users:
hidden link
display the parent view with below shortcode:
[wpv-view name="parent-view-samples-posts" author="[wpv-user field="ID"]" cached="off"]

3) Parent view, list all "samples" posts
hidden link
display the child view with below shortcode:
[wpv-view name="child-view-answer-posts" cached="off" author="[wpv-attribute name="author"]" sampleid="[wpv-post-id]" cached="off"]

4) Child view, list answer posts, filter by:
a) Select posts that are children of the Post with ID set by the shortcode attribute sampleid.
eg. [wpv-view name="view-name" sampleid="123"]
b) Select posts which author's id is set by the View shortcode attribute "author" eg. [wpv-view name="view-name" author="1"]
And display the result as below:

	[wpv-items-found]
	<!-- wpv-loop-start --> <strong>Yes([wpv-found-count])</strong>
		<wpv-loop></wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]<strong>[wpml-string context="wpv-views"]No[/wpml-string]</strong>[/wpv-no-items-found]

5) Create a view, to list all all "samples" posts, use it as the table header:
hidden link

Please check if it is what you want. thanks

#595571

Excellent Luo, exactly what I need, thanks a lot!

I have made some changes to show only active samples:
hidden link

One last question: At "Grandparent view - Taster users" view, how can I order by user's Last Name?

Thanks again,
Kostas

#595785

As you can see, there isn't such a built-in feature within user view, if you agree, we can take it as a feature request, our developers will evaluate it. Thanks

#595806

Yes, please take it as a feature request, thank you.

Luo, your help is very much appreciated!
You can now close this ticket.

Best regards,
Kostas

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.