Skip Navigation

[Resolved] CRED Shortcode to delete posts doesn't works fine

This support ticket is created 2 years, 9 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.

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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 14 replies, has 2 voices.

Last updated by Christian Cox 2 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#2126403

I am trying to:
I have created a Content Template with a View to display the button, inside a special area "My profile" where it is displayed the CPT Profile post that the author has created, which the authors can delete their posts, it worked before the last update, but now the button disappear.
The shortcode that I have used inside the View loop is:

[cred-delete-post action='trash' onsuccess='45' item='[wpv-view name="id-autore-loggato"]' message_after='Profilo eliminato' message='Sei sicuro di voler cancellare il tuo profilo?' message_show="1" class='delete cancel trash tastofooter'] [/cred-delete-post]

and the CSS style that I have assigned to the View is:

.wp-block-image .tb-image  img { border-radius:150px !important}
.wp-block-image { margin-bottom: 0em;}
.et-l--body ul.wp-block-social-links {padding:0;}
.social .tb-button__link {  font-size: 20px; margin-bottom: 0;}
.facebook .tb-button__link { padding: 6px 12px;}
.instagram .tb-button__link { padding: 6px 9px;}
.twitter .tb-button__link { padding: 6px 9px;}
.youtube .tb-button__link { padding: 6px 8px;}
.tb-button__link{margin-bottom:0;}
.tasti-funzione .tb-button .tb-button__link {width:100%;}

The CSS style that I have added in the content template is:

a.trash::before {font-family:'FontAwesome'; content:'\f1f8'; color:#ffffff;}
a.trash { font-family:'FontAwesome'; padding: 7px 12px;
background: red;
color: #fff;
border-radius: 40px;
font-size: 18px;
box-shadow: rgba(0, 0, 0, 0.15) 0px 4px 12px 0px;
display: block;
}

Link to a page where the issue can be seen:

I expected to see: the delete button

Instead, I got: nothing

#2127205

Hello, are you saying this is a CSS issue where the button exists but cannot be seen, or the button is not included at all on the front-end? I can check if you provide information about where I can look to investigate. If I need login credentials, please provide those in the private reply fields here.

#2128277

1. I see two Views involved here. The first View is "link cancella Mio Profilo". The second View, "id-autore-loggato" is nested inside the cred-delete-post shortcode's item attribute. Neither View produces results for the Assistenza User, so I'm not really able to test the delete post link effectively. Should I publish a post manually from wp-admin, or would you prefer to log in as Assistenza and publish one test post for me using some specific post details?

2. I see the item attribute of the cred-delete-post shortcode contains a View. This seems like it might be a problem. Views often produce content that should not be included in the item attribute, like extra spaces and comments. I do not really understand why two Views are necessary here. It seems like you could just use one View, "link cancella Mio Profilo", and remove the "item" attribute from the cred-delete-post shortcode...but, again, I do not really understand which post you want to delete. I think it will be helpful for me if the two Views produce some result for the Assistenza user.

#2128327

Well, you need to create a test profile. To do that, you need to log in as Assistenza and to go here hidden link. On the right of the page, you will find a green button with "+" icon, click on it, on the new page click on "Attività Nautiche" and you will be redirected to the Form to create a profile page.

After you have created the profile page, you will be redirected to your public profile page. Then, you need to go there hidden link to see on the right button to edit your profile page, and would be the button to delete your own profile post.

So, before the last updates, the Delete button was displayed and it works fine.

#2128387
area-riservada.png
scegli-macroarea.jpg

I'm confused, because I cannot find "Attivita Nautiche".
- I log in as Assistenza, then I go here: hidden link
I have attached area-riservata.png, showing what I see on this page.

On the right of the page, you will find a green button with "+" icon, click on it, on the new page click on "Attività Nautiche"
Okay yes I see the button, but when I click it I do not see "Attività Nautiche" anywhere. When I click the green "+" I am redirected to:
hidden link
See scegli-macroarea.jpg showing what I see here. I can't find Attivita Nautiche anywhere here, can you help?

#2128617

Ok, I'm sorry, like on the second screenshot, here hidden link, click on "Servizi Nautici"

#2128887

Thank you, I have updated the cred-delete-post shortcode. The original shortcode was:

[cred-delete-post action='trash' onsuccess='45' item='[wpv-view name="id-autore-loggato"]' message_after='Profilo eliminato' message='Sei sicuro di voler cancellare il tuo profilo?' message_show="1" class='delete cancel trash tastofooter'] [/cred-delete-post]

I turned off caching in this View, and I also placed the new shortcode and some hidden debug information in the View by editing the Content Template here:
hidden link
New shortcode and debug text:

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

If you inspect the delete button using the developer tools, you will be able to see some debug information about the post being deleted. It will not be displayed to the end user, but is available for debugging purposes now.

In the new shortcode, you can see I removed the item attribute and nested View. Those were unnecessary and ultimately broke the delete link. I also removed the attributes message_after, message, and message_show as they are currently unsupported in this shortcode:
https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred-delete-post

The blank space inbetween the shortcode tags is required, otherwise no button will be displayed. It seems to be working correctly now. I was able to see the red trash can icon button, and when I clicked it I was able to delete my Attivita Nautiche post from the Scegli Macroarea page here: hidden link

After clicking the delete link I was redirected to the Home page (post ID #45, set in the onsuccess attribute). My Attivita Nautiche post now appears in the Trash.

So it seems be working correctly now, can you clear your browser cache and confirm?

#2128939

Thank you Christian, now I can see the red button with the trash icon.
Why after the new shortcode you have added the span?
And, are there alternatives ways to use the attributes to display a popup message to ask if the users are sure to delete their profile post, because I think that the users can accidentally press the delete button?

#2128983

Why after the new shortcode you have added the span?
I added it for debugging. Since I deleted the item attribute and nested View, I thought you might want to verify the correct post is being deleted. If you are satisfied and it is working correctly, feel free to delete the span. It is not required.

And, are there alternatives ways to use the attributes to display a popup message to ask if the users are sure to delete their profile post, because I think that the users can accidentally press the delete button?
Nothing exactly like that exists in the current software, unfortunately. There is no longer a confirmation workflow built into the cred-delete-post shortcode, so those alternate attributes do not exist. If you want to add a confirmation workflow you would need to add that workflow some other way using your own custom code. For example, you could place the cred-delete-post shortcode in a div that is hidden with CSS like display:none; Display a link that says "delete post", or something similar, instead of the cred-delete-post link. Use JavaScript to show the hidden div when the User clicks the "delete post" link.

Another option is to place the cred-delete-post link on a separate page. In that separate page you can include the confirmation message. Back in the original page, display a link to the new page instead of the cred-delete-post shortcode.

#2129185

Ok, thank you.
So, I have found a guide to creating a popup with Divi, I will try with it!

Thank you so much!

#2129261

Sure, sounds good. Just be aware that the cred-delete-post link should probably be included in the page when the page loads. Not sure if the popup uses AJAX, but if so, the cred-delete-post link may not function as expected.

#2129275

Well,
this is the link to the guide to creating a popup using Divi using jQuery.
hidden link

So, I have done it, and the popup works fine on desktop (I don't have tried to delete the post), but to see the popup on mobile I have to hold the button otherwise the popup disappears… this is very strange!

#2129503

I see what you mean about the mobile popup trigger. Unfortunately it does not seem to be Toolset-specific. This overlay and trigger interaction is inconsistent. The behavior changes depending on the button location, the overlay and content location, and the precise location of the touch/click. Check out this test site / test page I created with Divi. No Toolset plugins are active.
https://onyx-maraca.sandbox.otgs.work/divi-test/

I set it up using the code and instructions from the tutorial you provided, and the same problem can be seen on mobile devices in some cases. Scroll down to the the "Open popup" link. I find that if I click the word "Open", the same problem happens. If I click the word "Popup", the problem does not always occur.

I'll send login credentials in a private reply in a moment.

#2129541

Thank you Christian,
I have found a solution using z-index. The mobile button menu section needs to have a z-index value > than the z-index of the popup section

#2130969

Very good, sounds like an effective solution.

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