When you go to the profile of a user and try to send them a message you will get the error recipient is required. I found out in the blocks/class-message-send-form.php it’s trying to gather the user_id from the request params, but the user_id isn’t set, the username is.
## Steps to reproduce
- Go to default user profile
- Try to send them a message
## Actual result
- Get error that recipient is not set
## Expected result
I would expect to be able to send a message
## Extra details
I’ve fixed it by retrieving the user_id by the username.
// Check if 'user_id' is in the request parameters.
$recipient = hivepress()->request->get_param( 'user_id' );
// If 'user_id' is missing, retrieve it from the 'username' parameter.
if ( empty( $recipient ) ) {
$username = hivepress()->request->get_param( 'username' );
if ( $username ) {
$user = get_user_by( 'login', $username );
if ( $user ) {
$recipient = $user->ID;
} else {
error_log("Username '{$username}' not found.");
$recipient = null;
}
}
}
if ( $recipient )
$this->values['recipient'] = $recipient;