Skip to content

Instantly share code, notes, and snippets.

@qstudio
Last active April 26, 2016 19:56
Show Gist options
  • Save qstudio/a4fa6c7b5f7fbf9ce871 to your computer and use it in GitHub Desktop.
Save qstudio/a4fa6c7b5f7fbf9ce871 to your computer and use it in GitHub Desktop.
public static function delete_signup( $key ) {
// get signup from $key ##
$signup = GFSignup::get( $key );
// return error, if nothing found ##
if( is_wp_error( $signup ) ) {
return $signup;
}
// grab user ID ##
$user_id = username_exists( $signup->user_login );
if ( $user_id ){
// log ##
GFUser::log_debug( "Failed to delete signup for username: {$signup->user_login} - entry: {$signup->lead["id"]}" );
// username already exists, they must have been activated in another way ##
return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup );
} else {
// log ##
GFUser::log_debug( "Delete signup for username: {$signup->user_login} - entry: {$signup->lead["id"]}" );
// hook - send all signup data Array ##
do_action( 'gform_delete_user', $signup );
// grab database object ##
global $wpdb;
// delete row from signups table ##
return $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->signups WHERE activation_key = %s", $key ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment