Skip to content

Instantly share code, notes, and snippets.

@cryptexvinci
Created April 5, 2023 02:44
Show Gist options
  • Save cryptexvinci/f0c3266163244944016b1efbf9f440ec to your computer and use it in GitHub Desktop.
Save cryptexvinci/f0c3266163244944016b1efbf9f440ec to your computer and use it in GitHub Desktop.
Set the default value for private messaging option on user register or add.
<?php
/**
* Set the default value for private messaging option on user register or add.
* @param int $user_id The ID of the newly registered user.
* @return void
*/
function um_change_who_can_pm_default( $user_id ) {
// Set the default value for private messaging option to 'friends' for the new user.
update_user_meta( $user_id, '_pm_who_can', 'friends' );
}
add_action( 'user_register', 'um_change_who_can_pm_default', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment