Created
April 5, 2023 02:47
-
-
Save cryptexvinci/64c8f6b478578a2b0162c4c0947e3288 to your computer and use it in GitHub Desktop.
Update private messaging option for all existing users.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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