Skip Navigation

[Resolved] Conditional based on author id from parent post not working

This support ticket is created 7 years, 1 month 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
- - 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 13 replies, has 2 voices.

Last updated by Beda 6 years, 7 months ago.

Assisted by: Beda.

Author
Posts
#574545

Can you please explain why this conditional display doesn't work in a CRED edit post form?
It ignores the id='$organizer'.
I use it in layouts without issues.

[wpv-conditional if="('[wpv-current-user info='id']' ne '[wpv-post-author format='meta' meta='ID' id='$organizer']') AND ( '[wpv-current-user info='role']' ne 'administrator' )"][/wpv-conditional]
#574803

These conditionals work on my end.

Here an example, used in a CRED Edit Form, that is inserted to a Post which has a parent Assigned:

[wpv-conditional if="( '[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='ID' id='$package']' )"]
  Here
[/wpv-conditional]

There can be several issues here:
- the post has no parent
- there is a typo in the parent slug
- the form is not an edit form

Can you try to output just the part "[wpv-post-author format='meta' meta='ID' id='$organizer']" to see what it Outputs?

Please let me know.

#575686
edit post form layout.png
conditional output in edit form.png
single post conditional.png

I added this to both the edit form and to the single post layout.

<p>[wpv-current-user info='id'] = [wpv-post-author format='meta' meta='ID' id='$organizer'] OR user-role = [wpv-current-user info='role']</p>

On the single post it outputs correctly but in the cred edit form parameter id='$organizer' is ignored. I only get the post-author from current post.

Maybe it is because I use the "new" way to edit-post-links? I assigned a layout to the edit post link.

[toolset-edit-post-link layout_slug="redigera-bokning" target="blank"]Redigera Bokning[/toolset-edit-post-link]

I also tested to add another field to the form. The parent parameter is ignored for post-title as well.

[wpv-post-title id="$organizer"]

The last test was to add a field to another row in the edit post layout. I works, but not in the form.
see image.

#575709

In my local test, this works as well fine with the Layouts edit mode.

Is it possible to provide to me a small snapshot of this site?

Thanks!

#576020

OK, I tested this.

I used the User provided by you.
This User (User149) is not the author of the Current Post we are editing with CRED here (Post 10468).
Post 10468 is authored by User 166.

The parent of this post is as well authored by User 166.

I used your CRED form and removed the long list of Post fields to address just the output of current user, current post author and parent post author IDs

The output is correct.

These conditionals work perfectly fine for me on your Duplicator:

[wpv-conditional if="('[wpv-user field='ID']' ne '[wpv-post-author format='meta' meta='ID' id='$organizer']') AND ( '[wpv-current-user info='role']' ne 'administrator' )"]
You are neither admin nor author of parent post
[/wpv-conditional]

Does it work for you too, after copy paste this?

#576093

The author of the current post is 166
The author of the parent post is 149 (id=organizer)
The output is incorrect. Parameter for parent post is ignored.

Try to put this in the form, outside any other condition. You will see that the parameter for organizer is ignored.
The output should not be the same for both short-codes.

[wpv-post-title id="$organizer"], [wpv-post-title]
#576402

The post bookings/bokning-nr-10468/ is authored by User 166.
I log in as User 149.

I used this ShortCodes in the CRED Form:

Current user ID:[wpv-user field="ID"]<br>
Current Post Author ID: [wpv-post-author format="meta" meta="ID"]<br>
Parent $organizer Author ID: [wpv-post-author format="meta" meta="ID" id="$organizer"]<br>

I see on the front end:

Current user ID:149
Current Post Author ID: 166
Parent $bookings Author ID: 166

Hence, you are right, the $bookings is not respected. I confused the output earlier.

I could still not replicate this on a clean install.

So I started to deactivate and remove things from the Duplicator.
After I removed all the Plugins and the add-on files from the FTP the issue was gone on your site.
Now, the correct IDs are shown.

I also changed the theme in this process.

Something is resetting the Post Object on your Website.

I deployed the package again and tried to narrow down the culprit, so I also had the chance to test directly with your original Form.

- Use Twenty Seventeen Theme ==> Issue is solved.

I should have seen that earlier in the process, I apologise.

Can you confirm that switching the Theme solves the issue?

#576619

First test:
Switching to Toolset Starter theme 1.4.2 (don't have any other installed)
Leaving plugins active
Problem REMAINS

Second test:
Toolset Starter theme 1.4.2
Deactivating all except toolset (Access, Cred, Layout, Types, Views, Maps)
Problem REMAINS

Third test
Twenty Seventeen theme
All plugins except toolset active
Problem GONE

So whatever my theme is doing so is Toolset Starter theme.???? (Weird)

#576646

haha, some text changes to the third test.
Only toolset active others disabled ...

#576790

I discovered that this happens in all themes where Toolset Layouts is integrated with the_ddlayout() function.

As soon you remove that and use the_content() (which Toolset Layouts now replaces natively) then things work.

I will escalate this, but I need to update you about Layouts:
Meanwhile, Layouts is mainly intended as a Content Template Editor, not anymore an Editor for Header, Footer, etc.

Nonetheless, we need to look into this issue.

I will keep you updated here.

#577014

Meaning that I will have to rebuild my entire theme?

#577019

Confirmed. I changed the template to the_content()
But I must ask, why this is not informed with BIG LETTERS to users

#579318

You do not need to change this. It is a BUG which I reported already and we will solve this ASAP.

I have not yet any news to provide to you, but I have pushed for a fast solution.

Please stand by while I await news.

Thank you very much for your patience.

#629249

Hello Tina.

I believe this is solved in the current stable Toolset releases.

I tried hard to replicate it again but I cannot see this problem anymore.

Can you confirm that the problem is solved?