Edit postmeta when user changes user role?

I’m trying to update a postmeta field in the database called background-video. I want to clear the value from this when a user has changed the role to a user role called basic.

I found this code, which from what I understand runs when a user has changed role to the user role “basic”.

add_action( ‘basic’, function( $user_id, $role, $old_roles )
{
// Your code …

}, 10, 3 );

The problem is I don’t know how to target all the postmeta fields called background-video and clear the meta-value from them.

Read more here:: Edit postmeta when user changes user role?

Leave a Reply

Your email address will not be published. Required fields are marked *