Skip Navigation

[Resolved] Delete post function using CRED shortcode (how to do)

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)

This topic contains 5 replies, has 2 voices.

Last updated by Minesh 1 year, 7 months ago.

Assisted by: Minesh.

Author
Posts
#2583771
02.png
01.png

Tell us what you are trying to do?
I'm creating an Online Menus site, where bar and restaurants can create their own profile and add their menus.
To project this I'm using Blocks addon.
I have created 3 different CPTs: Restaurants, Menus, and Allergens. Where Restaurants CPT has a one-to-many relationship with Menu CPT, and Menu CPT has many-to-many relationships with Allergens CPT.

I have created a Custom Template to show the Logo, Name, and description of the restaurants. In the footer, I have added a section where are showed the complete post list of the allergens CPT.

In the middle, I have added a View to show the Menu items related to the restaurant, and it works fine. In the View filter I have set this: Select posts in a Restaurants Menus relationship that are related to the Post where this View is shown.
In this View, I have added a button to edit the Menu item, and also I have added a button to open a popup with a button (generated using a View) to delete the Menu item that I want to delete (but it doesn't delete the post I want to delete, it deletes the last Menu item that I have created).

The code I have used in the Menu item delete button to open the popup is:

<p style="text-align: center;"><a class="delete cancel trash tastofooter popup">cancella</a><span style="display: none;">Delete post [wpv-post-id]:[wpv-post-link]</span></p>

The code I have used in the View to display the delete Menu item button in the popup is:

[cred-delete-post action='trash' onsuccess='45' class='delete cancel trash-popup tastofooter']<i class="fas fa-trash-alt"></i> Cancella prodotto[/cred-delete-post]<span style="display:none;">Delete post [wpv-post-id]:[wpv-post-link]</span>

In screenshot 1 you can see the Menu items list with the Delete and Edit buttons, and I have added the relative post-id

In screenshot 2, that is the popup with the delete button, I have also added the post-id and the post title to see if it deletes the Menu item that I want to delete, but it displays the post-id and title of the last Menu item I have created.
I think that I need to set the Query Filter in View using Post ID or something.

Can you help me to do what I need?

Is there any documentation that you are following?
To do that I have used this guide https://toolset.com/forums/topic/cred-shortcode-to-delete-posts-doesnt-works-fine/#post-2128983
and for the popup, I have used this guide hidden link

Is there a similar example that we can see? I don't know

What is the link to your site? hidden link

#2584007

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I would like to know that do you want to delete the post or you want to disconnect the post relationship between your posts?

Can you please share problem URL where I can see those buttons you added and few sample post that I should try to delete and let me know your expected results.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) 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.

#2585509

Hi Minesh,
I have created a page, called "Il mio menu", like "My Account", where the users can find all their related Menu items and there they can click to edit or delete the Menu item they need.
hidden link

If there is a way to disconnect the single Menu item form the relationship and display at which CPT the single Menu item is related, I prefer to use this solution.
And also, it would be useful to implement the solution to delete the item using the popup like my first question.

Please, don't click to delete any existing Menu items. You can create a new Menu item and test with it.
Thank you

#2586571

Minesh
Supporter

Languages: English (English )

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

Can you please try to use the following shortcode to delete the post:

[cred_delete_post_link action='trash' redirect='self' message='This post will be deleted. Are you sure?' message_show='1' class='cred-refresh-after-delete']Delete This Resource[/cred_delete_post_link]
#2586931

Hi Minesh,
thank you for your reply.
Your solution works fine!

#2587417

Minesh
Supporter

Languages: English (English )

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

Glad to know that the solution I shared help you to resolve your issue.

You're welcome to mark resolve this ticket.