Skip to content

Instantly share code, notes, and snippets.

@cryptexvinci
Created April 5, 2023 02:47
Show Gist options
  • Save cryptexvinci/64c8f6b478578a2b0162c4c0947e3288 to your computer and use it in GitHub Desktop.
Save cryptexvinci/64c8f6b478578a2b0162c4c0947e3288 to your computer and use it in GitHub Desktop.
Update private messaging option for all existing users.
<?php
/**
* Update private messaging option for all existing users.
* @return void
*/
function um_update_existing_users_pm_option() {
// Get all existing users.
$users = get_users();
// Loop through each user and update their private messaging option to 'friends'.
foreach ( $users as $user ) {
update_user_meta( $user->ID, '_pm_who_can', 'friends' );
}
}
add_action( 'wp_loaded', 'um_update_existing_users_pm_option' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment