// Call to delete a member record.
trigger_error( 'Delete for member with id:' . $memberId, E_USER_NOTICE );
+ // Setup all folders for images. Including original.
+ $imageSizes = $this->config['imageSizes'];
+ $imageSizes['original'] = 'Original';
+
// Delete Member Info Records.
// Get all member Info Records (for url's)
$memberInfoRecords = $this->wpdb->get_results(
WHERE ref_type = 20
AND ref_dest = %d",
$info['id']
- )
+ ),
+ ARRAY_A
);
if ( $files ) {
foreach ( $files as $file ) {
// Remove this file.
- unlink( GLM_MEMBERS_PLUGIN_FILES_PATH . '/' . $file );
+ unlink( GLM_MEMBERS_PLUGIN_FILES_PATH . '/' . $file['file_name'] );
}
}
$this->wpdb->delete( GLM_MEMBERS_PLUGIN_DB_PREFIX . 'files', array( 'ref_type' => 20, 'ref_dest' => $info['id'] ), array( '%d', '%d' ) );
WHERE ref_type = 20
AND ref_dest = %d",
$info['id']
- )
+ ),
+ ARRAY_A
);
if ( $images ) {
foreach ( $images as $image ) {
// Remove this file.
- foreach ( $this->config['imageSizes'] as $k => $v ) {
- unlink( GLM_MEMBERS_PLUGIN_FILES_PATH . '/' . $k . '/' . $image );
+ foreach ( $imageSizes as $k => $v ) {
+ unlink( GLM_MEMBERS_PLUGIN_IMAGES_PATH . '/' . $k . '/' . $image['file_name'] );
}
}
}
$this->wpdb->delete( GLM_MEMBERS_PLUGIN_DB_PREFIX . 'images', array( 'ref_type' => 20, 'ref_dest' => $info['id'] ), array( '%d', '%d' ) );
+ // Delete member logo if it exists.
+ $memberLogo = $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT logo
+ FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info
+ WHERE id = %d" ,
+ $info['id']
+ )
+ );
+ if ( $memberLogo ) {
+ foreach ( $imageSizes as $k => $v ) {
+ unlink( GLM_MEMBERS_PLUGIN_IMAGES_PATH . '/' . $k . '/' . $memberLogo );
+ }
+ }
+
// Delete category_member_info.
$this->wpdb->delete( GLM_MEMBERS_PLUGIN_DB_PREFIX . 'category_member_info', array( 'member_info' => $info['id'] ), array( '%d' ) );
}
}
+
// Delete member_detail_stats.
$this->wpdb->delete( GLM_MEMBERS_PLUGIN_DB_PREFIX . 'member_detail_stats', array( 'member' => $memberId ), array( '%d' ) );