Recipient is required when try to send a message

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;

Hi,

We checked this issue from our side, and it seems okay. Please disable third-party plugins and customizations (if there are any) and check if this issue persists. If you use a caching plugin, make sure that caching is disabled for logged-in users. If this issue exists, please provide more details (e.g., your actions step by step with screenshots, screencast, etc.). This will help us to reproduce and resolve the issue faster.

Hello,

I came across the same problem.
I provided a workaround here (basically output the HTML myself), as the recipient is not properly set, even though it exists and shows (debug info).

Hope this helps.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.