Advertisement
verygoodplugins

Untitled

Oct 10th, 2019
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. function wpf_delete_user() {
  2.  
  3.     $post_data = apply_filters( 'wpf_crm_post_data', $_REQUEST );
  4.  
  5.     if ( empty( $post_data ) || empty( $post_data['contact_id'] ) ) {
  6.         wp_die();
  7.     }
  8.  
  9.     $args = array(
  10.         'meta_key'   => wp_fusion()->crm->slug . '_contact_id',
  11.         'meta_value' => $post_data['contact_id'],
  12.         'fields'     => array( 'ID' ),
  13.     );
  14.  
  15.     $users = get_users( $args );
  16.  
  17.     // If user is found
  18.     if ( isset( $users[0] ) ) {
  19.  
  20.         wp_delete_user( $users[0]->ID );
  21.  
  22.     }
  23.  
  24.     do_action( 'wpf_api_success', $users[0]->ID, 'update' );
  25.  
  26. }
  27.  
  28. add_action( 'wpf_delete', 'wpf_delete_user' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement