Skip Navigation

[Resolved] ¿Can do a php action or shortcode on delete creed link?

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

Last updated by rafaelL-2 3 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1676141

Tell us what you are trying to do?

Like same that cred_save_data can do action when save a new post type, are any fuction to do on delete link accion? example send a mail to X person.

#1677019

Hello, there is no hook specifically for the cred-delete-post shortcode, but WordPress offers the before_delete_post hook: https://codex.wordpress.org/Plugin_API/Action_Reference/before_delete_post

You can test to see if the post being deleted is a specific post type and trigger some relevant custom code like this:

add_action( 'before_delete_post', 'before_delete_function' );
function before_delete_function( $post_id ){

  // delete the next three lines if you want to trigger the code when deleting a post in wp-admin
  $screen = get_current_screen();
  if( is_admin() && $screen )
    return;

  $post_type = get_post_type( $post_id );
  if ( $post_type == 'book' ) {
    // add your custom code here
  }
}

Replace "book" with the slug of your custom post type.

You can configure the cred-delete-post shortcode to trash a post or delete a post. The hooks above are used when you want to delete the post. You can see Minesh's answer in another ticket to see how to use the post_updated hook to check to see if the post was trashed:
https://toolset.com/forums/topic/before_delete_post-hook-not-working/#post-566759

#1688207

Gracias me fue muy bien

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