Skip Navigation

[Resolved] Multiple alert dialogs warning of deleting post and user on cred-delete-post

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 1 reply, has 1 voice.

Last updated by davidL-7 12 hours, 10 minutes ago.

Assisted by: Minesh.

Author
Posts
#2850250

Hi, we're getting a bug in our Toolset-based app when a user deletes a post. We have a staging copy of the site set up so that we can test it without impacting the live production site, and I have been able to replicate the behavior. Here's a description of the bug we're encountering:

1) On the Current Aid Requests page (hidden link), the user with administrator-level permissions clicks the trash icon next to an aid request to delete it.

2) An alert dialog opens saying "Are you sure you want to delete this aid request? There is no undo." So far, so good.

3) On pressing OK, the same alert dialog appears again.

4) Pressing OK again, the same alert dialog appears a third time.

5) Pressing OK on the third dialog, a dialog opens saying "Are you sure you want to delete this person's user account?"

6) Pressing OK on that dialog, the deletion runs and the Aid Request is deleted.

So the delete action works, but the multiple dialogs are confusing and the question about deleting the user account scares the user (though so far we have not detected any user accounts actually getting deleted).

Here's a description of how it's built:

1) The trash can icon next to each Aid Request post listed on hidden link is a

[cred-delete-post action='trash' onsuccess='self' class=' delete-notice']

link. See the View named "List Aid Requests - NPS".

2) In the same View ("List Aid Requests - NPS"), in the JS Editor there's a javascript function that triggers the alert:

<pre>
//Alert notice
var btn = jQuery(".delete-notice");
btn.data("funcToCall", btn.attr("onclick"));
jQuery(".delete-notice").removeAttr("onclick");
jQuery(".delete-notice").bind("click", function(e){
if(confirm("Are you sure you want to delete this aid request? There is no undo.")){
var func = jQuery(this).data("funcToCall");
eval(func);
} else {
return false;
}
});
</pre>

This is obviously where the first alert dialog is being produced, but I'm not clear why it's getting triggered mulitple times.

Also, I'm not aware of any code that would produce the "Are you sure you want to delete this person's user account?" dialog, or why it's being triggered.

We'll provide you with admin access so that you can take a look. I've created three Aid Requests that you're welcome to delete to replicate the behavior (2026 - 7, 2026 - 8, and 2026 - 9), and you're welcome to add new requests as needed to test with.

It's probably worth noting that the Aid Request post is meant to have related Aid Items added to it, and I thought that the multiple dialogs might be related to those related child Aid Items posts getting deleted when the parent Aid Request post is deleted, but I got the same multiple dialogs even on an Aid Request post with no Aid Items added to it.

I'm hoping you can determine why this is happening and how to fix it! What we want is just the single Are You Sure alert, and then on pressing OK once, the deletion.

Thanks!
David

#2850285

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I've disabled (comment out) the custom JS code you added to your view:
- hidden link

And replaced your existing [cred_delete_post] shortcode with the following shortcode:

[cred_delete_post_link action='trash' message='Are you sure you want to delete this aid request?  There is no undo.' message_show='1' class='cred-refresh-after-delete'  message_after='Aid Request Deleted.']<span class='et-pb-icon'>&#xe07d;</span>[/cred_delete_post_link]

Can you please confirm it works as expected.

#2850364

Thanks Minesh, I tested it and it now works as desired. Thank you, I appreciate the support!!