How to add welcome message for new users?
This snippet will add welcome message on user register when you are using BuddyPress in your website. It will work with BP Better Messages plugin perfectly. If you are running BP Better Messages without BuddyPress plugin, this action will not work, but the function will work still, so you need attach it to other action.
function bp_messages_welcome_message( $user_id = false, $key = false, $user = false ){ if ( ! function_exists( 'BP_Better_Messages' ) ) return false; $args = array( 'sender_id' => 1, 'thread_id' => false, 'recipients' => $user_id, 'subject' => 'Welcome to WordPlus.org', 'content' => "<strong>Welcome to WordPlus.org</strong>\n\n If you have any question about <strong>BP Better Messages</strong> you can ask it here directly.", 'date_sent' => bp_core_current_time() ); $result = BP_Better_Messages()->functions->new_message( $args ); } // For BuddyPress add_action('bp_core_activated_user', 'bp_messages_welcome_message', 10, 3); // For BuddyPress (if first one does not works) add_action('bp_core_signups_after_add_backcompat', 'bp_messages_welcome_message', 10, 1); // For Not BuddyPress add_action('register_new_user', 'bp_messages_welcome_message', 10, 1);
Perfect place to put this snippet is child theme functions.php file.