Skip Navigation

[Résolu] Issues with parent content template

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.

This topic contains 10 réponses, has 2 voix.

Last updated by jamesH-3 Il y a 7 années et 4 mois.

Assigned support staff: Paweł Pela.

Auteur
Publications
#232397
screenshot6.png
screenshot5.png
screenshot4.png
screenshot3.png
screenshot2.png
screenshot1.png

Hi
I have set up a content template for the parent (merchant). The parent content template includes a view to list the child content (coupon).

It does work fine for users who do not have to log onto an account.

However, if you are an administrator or a merchant, logged into your account, and go to the merchant pages, you can only see the coupon view of the account you are logged on.

For example, james-hille-hotel was created by and assigned to the administrator (refer to the screenshot 1 to see how the page looks when no one is logged on)

If another merchant logs on (in this example dreaming), they can see their own page with no problem (screenshot2).

However when the logged on merchants checks any other merchant posts, the coupons view does not appear (screenshot3)

I have also attached the screenshots of the view in questions (screenshots 4-7)

Thanks

#232417

Dear James,

I think this is related to how you set up your user accounts (Editor role).

Please install and configure Access to control you CPTs and users and see if it fixes your problem. If it doesn't, we'll go from there and try to find the reason why it's not working.

Regards,
Paweł

#232428

Hi Adriano
I have installed and activated Access and ticked the boxes to manage CPTs (Coupon and Merchant). Although read option is selected for all users, nothing has changed.
Thanks

#232444

Dear James,

I've been checking your site and I tried to update the view settings a bit as this may sometimes help if they had been incorrectly saved. Please test this and tell me if it did change anything.

If not, then this is a bug and I will report it to our developers.

As a side note: please try also creating a new user role (Merchant for example) and assigning permissions to it.

Regards,
Paweł

#232540

Hi Pawel

I have checked it again and the issue is still there.

When do you think I should hear from you or the developers about this bug?

PS: Thanks for your suggestion about the Merchant user role

Thanks

#232558

Dear James,

Yes, this unfortunately seems to be a bug.

I would like to get an exact copy of your website for our developers to test and look for the problem first.

As we don't want to interfere with your original site, I'd like to ask you for a permission to create a Duplicator package (https://wordpress.org/plugins/duplicator/) which contains all the files and a database dump.

As soon as I can create a Duplicate, I will report this to our developers and I will be able to tell you how fast it will be fixed.

Regards,
Paweł

#232601

No worries

#232613

Dear James,

I've created a Duplicator package and I'm downloading it now. I will try to duplicate this issue on my server, and then I will send a bug report to our developers.

I will update you as soon as I get some more informations.

Regards,
Paweł

#232625

Dear James,

I have confirmed that this problem exists also on my testing machine. I'll write a bug report to our developers now.

They will take a look at the Duplicator package I will send them and try to fix the bug. As soon as I get a patch for this, I will send it to you via email.

For now, I'll mark this thread as closed, but if you have any other problems or questions, please open a new one.

Regards,
Paweł

#233766

Dear James,

We've found the problem. It was in a piece of code you've added to your functions.php:

add_filter( 'wpv_filter_query', 'views_filter_parents' );
function views_filter_parents( $query_args ) {
global $current_user;
if($settings['view_id'] = 201){ // WARNING!!
$query_args['author'] = $current_user->ID;
return $query_args; 
}
}

There are multiple problems with it. One is in the line I've marked with a WARNING. One thing is that you use an unknown variable $settings - where does it come from? And the second thing is that you make assignment (=) instead of comparison (==) - this means that the next line will be always executed for every View and it will limit displaying of posts everywhere.

Once you comment out this code, everything starts to work fine.

As for the View with ID 201, here's a comment from our lead developer: "Now, let’s look at the View with ID 201: “my merchants listing??. This is the View which seems to need to list only items created bu the same user viewing the results. I would stringly suggest adding a query filter by author there, and set it to filter by the current logged in author. This will have the same effect that the manual filter on the functions.php file had produced, but on a safe way. We have a GUI for that, so the custom code method is not recommended at all."

Hope this helps!

Regards,
Paweł

#233824

Hi Pawel

Thank you for looking into this and providing me with the update.

First of all, I have to say that I chose to use Toolset because I am not good at coding at all. The code that you are referring to was done and recommended to me to by one of your representatives, Adriano.

I was facing an issue to allow each merchant to post coupons only for their own businesses on their account page; however, the CRED form was allowing the merchant to post coupons for other businesses as well. That function was done by Adriano to address this issue. The solution was based on a recommendation, made by Ana Couto on another thread. Please refer to the links below:

https://toolset.com/forums/topic/cred-forms-parent-selector-fields/
https://toolset.com/2013/10/conditional-display-of-parent-posts-in-cred/
https://toolset.com/forums/topic/cred-forms-parent-selector-fields-2/

I did not notice that this function was the cause of this problem.

I really don’t know where to go from here. All I am asking for a user to be able to publish a post by using child fields? You would think that this would be an essential part of the whole Toolset idea without the need of custom coding.

I really need someone to address this issue. I strongly suggest to get in touch with your colleague, Adriano to find out what else can be done about it?

Please note that these issues have been going on since May 2014 and you would appreciate that I really would like a speedy solution and to move on to other tasks that I need to work on.

Thanks for your help