Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpml-gfur-delete-previous-image.php: Migrated. #986

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions experimental/gpml-gfur-delete-previous-image.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
<?php
/**
* Gravity Perks // Media Library + Gravity Forms User Registration // Delete Previous Image
* https://gravitywiz.com/documentation/gravity-forms-media-library/
* We're no longer using the experimental folder for experimental snippets. 🚧
* You can now find the snippet here:
* https://github.com/gravitywiz/snippet-library/blob/master/gp-media-library/gpml-gfur-delete-previous-image.php
*/
add_filter( 'update_user_metadata', function( $return, $object_id, $meta_key, $meta_value, $prev_value ) {

// Update "your_meta_key" to the user meta key you are mapping your GPML-enabled field to.
if ( $meta_key !== 'your_meta_key' ) {
return $return;
}

$prev_value = get_user_meta( $object_id, $meta_key, true );
$file_id = attachment_url_to_postid( $prev_value );
if ( $file_id ) {
wp_delete_attachment( $file_id );
}

return $return;
}, 10, 5 );
Loading