Skip Navigation

[Résolu] Control View’s output with Access

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
Is it possible to create a View that respects all Toolset Access rules set for a post type, even groups and single post settings of access?

Solution:
No, not without complex custom code.
A Feature is filed to allow this.
Please add your voice by opening a new ticket for it.

This support ticket is created Il y a 6 années et 12 mois. 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 43 réponses, has 5 voix.

Last updated by Beda Il y a 6 années et 4 mois.

Assisted by: Beda.

Auteur
Publications
#527736

Hi Beda... Not sure what the info you provided from the PHP site was for. Could you explain this further.

As for getting the conditional to work properly based on the presence of child posts is still not working for me. All posts are gone not just those that don't have posts in child view (345) due to use of Post Group. Must be missing something simple here in regards to conditionals as you have not provided any code based on the Beta Site made available via download.

Conditional code used in Loop

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<ul class="wpv-loop js-wpv-loop list-group">
		<wpv-loop>
          [wpv-conditional if="( '[sda_check_posts]' eq '0' )" evaluate="false"]
          <li class="list-group-item">[wpv-post-body view_template="Loop item in Project List View"]</li>
          [/wpv-conditional]
		</wpv-loop>
	</ul>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

Code used in functions.php file

add_shortcode('sda_check_posts', 'sda_check_posts_func');
function sda_check_posts_func() {
    $filtered_posts = get_view_query_results( 345 );
    if ($filtered_posts[0] == 0) {
        return 0;
    }
}
#528044

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

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

Hi Dave

Beda has a few days off and will be back working at the weekend. This is a very long thread so you'll forgive me if I don't read through it all and take it on myself.

Just looking at your code sample above, I take it that where you have $filtered_posts = get_view_query_results( 345 ) you are trying to see if the View with id 345 returns any results (specifically, does it return zero results).

get_view_query_results returns an array of post objects, and so if there are no matching posts it will return an empty array. So I think the test should look like this:

	if ( empty( $filtered_posts ) ) {
		return 0;
	}

Perhaps you can try that.

#528070

Oh My... This is becoming increasingly more frustrating and I have been severely bounced around. Appreciate your efforts and just for a little history as you are stepping into the middle of all this, this particular thread was started due to a complete lack of support in another thread and Beda chose to continue the topic here. The inquiries in the past several posts are the final part of an effort to get Access to provide control over posts that have been secured using the Access Post Group method.

Please don't allow this thread to be side tracked, we are almost to the finish line on what has become an exhausting marathon. Would value if you could take a moment and review all this in more detail and assist Beda with resolving this need.

Please note, when we get into custom code as a means of working around current Toolset software configuration limitations I am out of my depth. Trying so hard to be patient as I want to believe in Toolset as a solution for building serious business sites.

Kind Regards,
Dave

#529146

As I elaborated here:
https://toolset.com/forums/topic/important-need-senior-level-assistance/page/3/#post-523885

This exact code will use the View with ID 5.
If that View returns 0 results, the code returns 0, and when that happens, you do not display the View.
This means, in your HTML code you do:
"If is_there_a_post is not equal 0, display the view"
This looks like this:

[wpv-conditional if="( '[is_there_a_post]' ne '0' )"]Display your View[/wpv-conditional]

You also first need to register that ShortCode in the Toolset > Settings:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/ > Checking Custom shortcodes

#529881
Does not display any posts.png
Settings screenshot.png

I have done that as well... All it does is not display any posts as the value is going to come back as 0. Have provided you with the exact beta site, detailed info and more. I realize that Access currently has some limitations but I don't know what more to provide you with so you can provide the proper approach for displaying views and nested views based on their Access settings.

Perhaps you are missing something here, please feel free to ask me if you are not clear on any part of this as I need this to work properly. Help me help you, this is a much needed functionality for anyone trying to use Toolset Access professionally via the GUI configuration.

Below is some related code, most of which you already have. Perhaps this will help you see the bigger picture.

Kind Regards,
Dave

CODE: functions.php

add_shortcode('sda_check_posts', 'sda_check_posts_func');
function sda_check_posts_func() {
    $filtered_posts = get_view_query_results( 345 );
    if ($filtered_posts[0] == 0) {
        return 0;
    }
}

CODE: Project List View (ID 331) - Loop Output

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<ul class="wpv-loop js-wpv-loop list-group">
		<wpv-loop>
          [wpv-conditional if="( '[sda_check_posts]' ne '0' )"]
          <li class="list-group-item">[wpv-post-body view_template="Loop item in Project List View"]</li>
          [/wpv-conditional]
		</wpv-loop>
	</ul>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

CODE: Project List View (ID 331) - Loop item in Project List View

[wpv-post-title]
[wpv-view name="child-view-projects"]

CODE: Child View - Projects (ID 345) - Loop Output

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<ul class="wpv-loop js-wpv-loop">
		<wpv-loop>
			<li>[wpv-post-body view_template="Loop item in Child View - Projects"]</li>
		</wpv-loop>
	</ul>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
    [wpv-no-items-found]
        <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
    [/wpv-no-items-found]
[wpv-layout-end]

CODE: Child View - Projects (ID 345) - Loop item in Child View - Projects

[wpv-post-link]
#530776

Your Duplicator package does not return any item at all even if you check the View in the Layout, this means, there are simply not items to be returned.

I can not provide a customised Code built on a complex site where the initial data is not there.
This is simply not allowed by our Support Policy.
I gave all instructions and detailed code how this will work.
https://toolset.com/toolset-support-policy/

What I can do is try to craft this code more detailed for you, if you can send me an actual Duplicator Package with the Current Situation, that holds content.
On the package, you sent me there is no content to be used.

Furthermore, the code used in your Theme does not match any used View in your Install.
It matches the Test View, which is not even used.

I need a copy of the site where things are set up as they are intended to work, and I cannot provide custom code tailored to a specific site's need to support things that are not within the features of Toolset

Of course, I want it to be solved, but I cannot custom code and guess the code to use.
This is not my decision, it's our Support Guidelines.

I can help you with this, but I need a Package where it all uses the Views and Codes as we discussed until now so I can solve the issue of no returning Child Post Views.

I also tested your View 345, with the sda_check_posts shortcode, and that does NOT return 0 natively.
This means it returns 0 because of the specific setting of getting posts that belong to the parent post.

I also tried to rebuild your site so it actually would return some content without our Codes, it does not.
Since all Views query some Post Types that are not child or parent to each other, there is nothing to return.
This is what I have locally, and that is why I can not even test this - even if I can not code a customised solution.

Can you please provide me:

1. A valid copy of the actual site where everything is set up so as per your last description
2. A full user with content
3. What you want at the end (this should be clear, you want the parent view to not display anything if that child View has no content)

This is necessary to see why it's not returning.
I can then try to see what to adjust, but this is not within the code. It's because the View does not return any result.
Otherwise, the ShortCode would not give you 0.
You can also substitute the
if ($filtered_posts[0] == 0) {
return 0;
}
with
var_dump($filtered_posts); and see what it gives you.
If the View is empty, it will give you 0, otherwise an array of data.

If that is the case, all good, if not, you have to adjust the Child View, which we did not even touch with our code, to return some results.

#531051

All this is really trying my patience... Please take a beat and examine this matter in its entirety, you may find that I am trying very hard to be helpful. Toolset has some serious limitations with it's GUI as it pertains to Access. As for what I have made available to you in regards to the Testing Site, you have what I have, including users, pages, content and such. Yes I did customize the provided code to fit into the site we both have.

Take another day to get some perspective, you have a highly skilled information architect on the other end of this thread and I am trying to help move Toolset forward. Perhaps it is time to abandon Toolset as yet another short sighted software company not capable of seeing it's real potential and lacking the resolve to get there.

I hope I am wrong and you are actually just over run with the day to day goings on and missing the real opportunity here. You seem like a really smart engineer type, I value that, just need you to look beyond the code and today and see the needs of the future customer. Again, all my patience and efforts to help have been with the best of intentions. I really want Toolset to work as a professional piece of WordPress centric software where a tech savvy business owner can configure custom business solutions, apologies if this is not the goal of Toolset.

If you don't feel you can or want to continue this discourse please move this matter up to your superiors. No hard feelings from my end as I know how challenging it can sometimes be when trying to communicate via the written word only. Trust me when I say I fully respect and appreciate your skills as a software engineer and in no way looking for you to custom code or do any site configuration for me, was just looking to wrap things up as it pertains to the lack of Access GUI configuration settings so I can continue with the development of my companies project management site.

Kind Regards,
Dave

#531264

I understand.

I am sorry, but if that Duplicator site is an exact copy of what you have now, we spoke all time long about completely different Post Types, results, settings and code.

I do not think this is what you have running because, on the Duplicator, the things do not return results even without the custom code, and they query other post types.

This is why I ask for a current Duplicator, where you can indicate me the exact ID of the Views used, where they are used, who should see how many results, and where.

A few test Posts can be helpful to illustrate that before you create the Package.

This thread has been long also because we discuss approaches instead of working on the solution.

I want to close this. To solve this for you. I go over the line of Custom Code, for features that are not included in Toolset, and strictly speaking, I can not do that.

I want to solve this for you for several reasons, and I am certain, the only issue is a miss-setting in one of the views, or perhaps I need to adjust some of the code, as I used a site's copy that seemingly is not working as expected even without the code.

If you could send me that, I will even spend my weekend on it, but I need an actual, working example site.
With Paths to where, and who should see what posts.

Then I can adjust the solution, and instruct you how to apply it.

My superior (Mohammed) will ask the same. He also can not craft the solution based on that duplicator, as it is not producing what I expected on the first attempt, as I previously elaborated.

But if you wish, I can let him handle this.
Although, it will require again someone reading it, understanding it, and probably, asking again for details.

A current Snapshot, with a detailed path to where you want to see what, for a one-user example, will help us to craft your solution.

I appreciate your patience and understanding.

#532003
Dashboard page.png

Hey There Beda... Just so you are totally clear, the recent thread posts pertain to the Dashboard page which contains the parent and child Views for displaying brother posts. Again you should have all this.

As for setting up a duplicator package for you once again, it takes a little time as I have to strip some confidential info out. Again I believe you should have what I have.

I am not going to touch any of this for a few days. I need to reevaluate if Toolset is going to be the right fit for my professional needs. This is costing me a significant amount of time and getting the impression that this is not viewed by Toolset as an opportunity to improve things, just an annoying support thread.

#532098
User.png

1. https://toolset.com/forums/topic/important-need-senior-level-assistance/page/2/#post-521826

On your Duplicator Package, there is no "Sally" user
(see Screenshot "User")

Apologies if I miss some instructions on your end, but according to what I have you test this on a "Sally" user who does not exist.

2. None of the other existing Users has posted, in the Dashboard.
This is, after deploying the Duplicator Package and just visiting the Dashboard as each single user on the existing Package.

Do I have to create posts, Acces Rules, and similar, first?
I cannot do that. I need a site where the issue is visible.

As said, I did not alter in any way the existing package as you mention this is what you have now, and you mention that you see posts for the first View, but the nested View with the Childs is misbehaving.
So, I apologise again if here I got this wrong, please let me know what I need to change in this package so to see at least one user with some posts on the dashboard, so I can start to hide what you do not want to be there.

3. In the last Screenshot, you show me a user "Dave". This user, I suppose it's your admin user, is not existent neither on the package.
Do I need to make this work for Admins as well?

According to the code we address Subscribers, and the only subscriber on the package is a "TeamSDA-Sally", which has no posts in that Dashboard as per current situation of the package.

What I need:

1. What user to use so to test
2. What exact posts must show, which not (best case, a few example post slugs or ID's)
3. Which exact view do you plan to use here?

In the existing package you use the View "Project List View", and that View queries the post type "Project Groups".
It also nests the View "Child View Projects".
The parent View has no filters at all; the Child View has the parent/child filter.

As it is now, the View Project List View returns zero results, in all cases.
This is due to the specific Code added in functions.php as we discussed in this forum.

And I am not sure what the idea here is.
The code applies to View ID 257
But none of the involved Views has this ID.
Those are 345 and 331.
Additionally, you still run "!is_admin" which I mentioned removing here:
https://toolset.com/forums/topic/important-need-senior-level-assistance/page/2/#post-521517

I did analyse this now for some hours, and I do not know where, with what, and who should see what.

I apologise, that I can not wrap my head around it and that I cannot see the error.

I am sure I can solve this for you once I have clear instructions with the working copy of the site.
This can also be a slimmed down site, even better for me.

I seriously, and with me, the whole Toolset and OTGS people, are eager to help you.
This is what you pay; this is what we provide.

But I need some "solid" to work on, and as per the current situation, we need first to build this base, because as per my above-elaborated findings, this is not present at the moment on the data I have access to.

Thank you very much for your collaboration, professional help queries and understanding, not to mention your patience.

#534496

Hi Beda... After stepping back for a few days in an effort to gain perspective and deescalate any frustrations, I have decided to close this thread as it seems I must not be communicating something correctly.

Toolset is an amazing piece of software and I value your expertise. I will most likely be coming back to this need but will do my best to approach it as more of a one off solution.

Again, thank you for the solutions you did provide in this thread and for your willingness to be helpful.

Kind Regards,
Dave

#543440

I am reopening here with the sole purpose of updating the ticket as soon we have valuable work to show.
Thank you

#560727

We are still evaluating what we can do here.
I will keep you updated.

#594032

I am closing this ticket since the issues are gathered and the requests are filed.

To anyone interested, the ChangeLog will mention the updates once we implement them.

There is no road map yet, and the priority is given to the new Many To Many relations first.

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