Site icon Hip-Hop Website Design and Development

remove values within an array user meta

hello I save the values as here:
Add value to usermeta without removing previous values?

$email_suscriptor = $_POST['cancelsus'];

$dismissed = array_filter( explode( ',', (string) get_user_meta( $vendor_id, 'emails_suscriptores13', true ) ) );

if ( ! in_array( $email_suscriptor, $dismissed ) ) {
    $dismissed[] = $emailsus;
 $dismissed =  implode(",", $dismissed);
   update_user_meta( $vendor_id, 'emails_suscriptores13', $dismissed );
}

Result:

 $list_emails= get_user_meta( $vendor_id, 'emails_suscriptores13', true );

echo $list_emails;

so it looks:

1@gmail.com,2@hotmail.com,3@gmail.com

Users send their emails from a subscription form and I can save them with this code but I can’t delete their emails (values within the user meta)

the problem is that I can’t delete them

in my role I save emails from subscribing users so I need to be able to delete an email when someone wants to do it

try delete_user_meta, using the same code but it doesn’t work

Don’t work:

$cancelsus = $_GET['cancelsus'];

if (isset($cancelsus)) {

$dismissed = array_filter( explode( ',', (string) get_user_meta( $vendor_id, 'emails_suscriptores13', true ) ) );

if ( ! in_array( $cancelsus, $dismissed ) ) {
 $dismissed[] = $cancelsus;
 $dismissed =  implode(",", $dismissed);

   delete_user_meta( $vendor_id, 'emails_suscriptores13', $dismissed );
}
}