Skip Navigation

[Resolved] Creating Conditional for Edit/Delete Post

This thread is resolved. Here is a description of the problem and solution.

Problem:
Creating Conditional for Edit/Delete Post with

Solution:

You can find the proposed solution, in this case with the following reply:
https://toolset.com/forums/topic/creating-conditional-for-edit-delete-post/#post-1239019

Relevant Documentation:
https://toolset.com/documentation/views-shortcodes/#wpv-conditional
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

This support ticket is created 5 years, 7 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Tagged: 

This topic contains 11 replies, has 2 voices.

Last updated by Eric 5 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1238860

I am using the following conditional in my form for an Edit and Delete link to display for an author of a post. I need to change it so that anyone who is an editor or administrator can view the links. Any help appreciated.

[wpv-conditional if="('[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='ID']')"]
[toolset-edit-post-link content_template_slug="edit-listing"]Edit Listing[/toolset-edit-post-link] | [cred_delete_post_link class='cred-refresh-after-delete' text='Remove Listing' message='Are you sure you want to remove this listing?' message_after='Poof! Listing Removed. We moved it to the trash for safekeeping' message_show='0' action='trash' redirect='455']
[/wpv-conditional]

#1238954

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I would like to know here you want to keep the author condition or you want to replace the current condition with editor or administrator?

If you want to change the condition so that the edit link should be visible to editor or administrator.

You can use the access shortcode:

[toolset_access role="Editor,Administrator" operator="allow"]

[toolset-edit-post-link content_template_slug="edit-listing"]Edit Listing[/toolset-edit-post-link] | [cred_delete_post_link class='cred-refresh-after-delete' text='Remove Listing' message='Are you sure you want to remove this listing?' message_after='Poof! Listing Removed. We moved it to the trash for safekeeping' message_show='0' action='trash' redirect='455']

[/toolset_access]

#1238959
Screen Shot 2019-05-02 at 11.23.45 PM.png

Thank you, Minesh. Unfortunately, I see the shortcode on the frontend. See attachment. 🙂 Eric

#1238964

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Have you installed the access plugin? This shortocde belongs to Toolset access plugin.

Or

If you do not want to use the Toolset access plugin. You can use the following code:

[wpv–conditional if="( '[wpv-current-user info='role']' eq 'administrator' ) OR ( '[wpv-current-user info='role']' eq 'editor' )"]
  
[toolset-edit-post-link content_template_slug="edit-listing"]Edit Listing[/toolset-edit-post-link] | [cred_delete_post_link class='cred-refresh-after-delete' text='Remove Listing' message='Are you sure you want to remove this listing?' message_after='Poof! Listing Removed. We moved it to the trash for safekeeping' message_show='0' action='trash' redirect='455']
  
[/wpv–conditional]

More info:
https://toolset.com/documentation/views-shortcodes/#wpv-conditional
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

#1238969
Screen Shot 2019-05-02 at 11.37.47 PM.png

Unfortunately, I did not install the access plugin. But, when I replace the code you gave me with the [wpv-conditional ....] shortcode, the shortcode displays on the frontend.

I am using the latest version of the Divi theme without the new Divi Builder experience. 🙂

#1238975

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share problem URL and access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1238980

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - can you please share problem URL where you added the conditional shortcode?

#1238982

Yes. It's a listing at hidden link

#1239019

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've added the conditional shortcode as given under:

{!{wpv-conditional if="( '{!{wpv-current-user info='role'}!}' eq 'administrator' ) OR ( '{!{wpv-current-user info='role'}!}' eq 'editor' )" }!}

[toolset-edit-post-link content_template_slug="edit-listing"]Edit Listing[/toolset-edit-post-link] | [cred_delete_post_link class='cred-refresh-after-delete' text='Remove Listing' message='Are you sure you want to remove this listing?' message_after='Poof! Listing Removed. We moved it to the trash for safekeeping' message_show='0' action='trash' redirect='455']

{!{/wpv-conditional}!}

I can see its working now.:
=> hidden link

#1239131

Thank you, Minesh. It works!

One more question. When deleting a listing, it goes to the trash. Can display the trashed listings on the frontend? Or, when deleting a listing, can it be marked as archived and removed from the listings view and display in a view that only shows archived listings?

? Eric

#1239142

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Glad to help. That's different query. Please open a new ticket

#1239158

My issue is resolved now. Thank you!