Skip to content

Commit 1a410b8

Browse files
authored
gpml-gfur-delete-previous-image.php: Migrated.
1 parent 56e6249 commit 1a410b8

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed
Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
<?php
22
/**
3-
* Gravity Perks // Media Library + Gravity Forms User Registration // Delete Previous Image
4-
* https://gravitywiz.com/documentation/gravity-forms-media-library/
3+
* We're no longer using the experimental folder for experimental snippets. 🚧
4+
* You can now find the snippet here:
5+
* https://github.com/gravitywiz/snippet-library/blob/master/gp-media-library/gpml-gfur-delete-previous-image.php
56
*/
6-
add_filter( 'update_user_metadata', function( $return, $object_id, $meta_key, $meta_value, $prev_value ) {
7-
8-
// Update "your_meta_key" to the user meta key you are mapping your GPML-enabled field to.
9-
if ( $meta_key !== 'your_meta_key' ) {
10-
return $return;
11-
}
12-
13-
$prev_value = get_user_meta( $object_id, $meta_key, true );
14-
$file_id = attachment_url_to_postid( $prev_value );
15-
if ( $file_id ) {
16-
wp_delete_attachment( $file_id );
17-
}
18-
19-
return $return;
20-
}, 10, 5 );

0 commit comments

Comments
 (0)