Please navigate to HivePress > Settings > Users. If you set the Display Name option to, for example, Full Name, the vendor profile will also display the full name, since vendor names are linked to user names. Please note that this will only work after you change this setting and re-save the profile form for existing users, or for any newly created vendors.
We already have it set to Full Name but when a Vendor sends a messages or an offer it displays the First / Last name of the User rather than the Vendor they are associated with. We want to display the Vendor by itself (or both Vendor name and User name if required).
Please note that messages are sent on behalf of users, and the shown name is not the username but the display name, which is configured in HivePress > Settings > Users as mentioned above. If you’re familiar with code or have a developer, you can try customizing the template part that controls how the name appears in messages.
Yes, I understand that. I’m specifically looking to ALSO display the Vendor Name. I’ve tried editing both the message/thread/message-sender.php and messages/view/message-sender.php files (in both my theme and directly in the plugin. Nothing seems to work.
I was able to adjust the view for Offers to show both the Vendor name and Username but it’s slightly different right? i.e. Offers come from Vendors while messages come from Users.
There has to be a way to pull the name of the Vendor connected to that user though…
Here’s where I’ve gotten to - is there anything glaring I’m missing here:
<?php
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
$display = get_option( 'hp_user_enable_display' );
// Get the sender user ID
$sender_user_id = $message->get_author_id(); // or get_sender_id() depending on HivePress version
// Find the vendor associated with this user
$vendor_name = '';
$vendor_id = hivepress()->vendors->get_vendor_id_by_user( $sender_user_id );
if ( $vendor_id ) {
$vendor = hivepress()->vendors->get( $vendor_id );
if ( $vendor ) {
$vendor_name = $vendor->get_name() ?: ( $vendor->get_user() ? $vendor->get_user()->display_name : '' );
}
}
// Always show the WordPress user name
$user_name = $message->get_sender__display_name();
// Build combined display string
$display_name = $vendor_name ? $vendor_name . ' (' . $user_name . ')' : $user_name;
?>
<div class="hp-message__sender">
<?php if ( $display ) : ?>
<a href="<?php echo esc_url( hivepress()->router->get_url( 'user_view_page', [ 'username' => $message->get_sender__username() ] ) ); ?>">
<?php endif; ?>
<?php echo esc_html( $display_name ); ?>
<?php if ( $display ) : ?>
..</a>
<?php endif; ?>
</div>
Unfortunately we can’t help with customizations in detail, but we can provide general guidance. When overriding template parts, please make sure that the copied file path is correct, for example for the message sender link:
You can test if files are overridden by adding random text to the copied files, it should appear instead of the sender names on the messages and single conversation pages. You can get the vendor object by user ID this way: