Extending user registration system

We will be hooking into user_register, which provides us with a user ID for the currently registered user, which we will use to email the user a greeting and welcoming custom message of our own.

Make sure to provide a sender ID, and this is totally required, for the sake of simplicity I made it 1, which will be the first user on your blog and the admin. To find our your user ID, go to users, find your account, and click edit. Now in the address bar there will be something like ?user_id=ID_HERE . That’s the ID you should insert in the sender in follows-code.

Using BBP_messages_message::sender method

This method will allow us to insert the message. It takes 4 parameters, 3 required and one optional:

$user_id: (int) the recipient which we will direct the message to.

$message: (string) the custom message we are sending.

$sender: (int) the message sender user ID, which the user will be able to reply to (if possible) later upon login.

$notify: (bool) choose whether to notify this user by email about this message or not. It defaults to true, but you can set it to false to not email.

The coding:

Add the following code, to your child theme’s functions file or with a custom plugin, and make sure to make necessary edits such as customizing the message and inserting the message sender ID.