WordPress Plugin Overrides
You can override certain options used during the SSO process by our WordPress plugin.
Profile pictures (avatars)
Our plugin uses the get_avatar() function in WordPress to get the current user's profile picture URL.
Certain WordPress plugins may store avatars differently, and our plugin may be unable to retrieve the correct profile picture URL.
To fix this, you'll need to add a custom WordPress plugin to your website which overrides the URLs that are returned:
<?php
/**
* Plugin Name: Override Minnit Chat Profile Picture
* Description: Overrides avatar URLs returned by get_avatar() and get_avatar_url().
* Version: 1.0.0
* Author: Minnit Chat
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Retrieve custom avatar URL from user meta (`user-photo`).
*/
add_filter( 'get_avatar_url', function( $url, $id_or_email, $args ) {
$user = false;
if ( is_numeric( $id_or_email ) ) {
$user = get_user_by( 'id', $id_or_email );
} elseif ( is_object( $id_or_email ) && ! empty( $id_or_email->user_id ) ) {
$user = get_user_by( 'id', $id_or_email->user_id );
} elseif ( is_string( $id_or_email ) ) {
$user = get_user_by( 'email', $id_or_email );
}
if ( $user ) {
$custom_avatar = get_user_meta( $user->ID, 'user-photo', true );
if ( ! empty( $custom_avatar ) ) {
$url = esc_url( $custom_avatar );
}
}
return $url;
}, 10, 3 );
/**
* Replace avatar <img> output when using get_avatar().
*/
add_filter( 'get_avatar', function( $avatar, $id_or_email, $size, $default, $alt, $args ) {
$user = false;
if ( is_numeric( $id_or_email ) ) {
$user = get_user_by( 'id', $id_or_email );
} elseif ( is_object( $id_or_email ) && ! empty( $id_or_email->user_id ) ) {
$user = get_user_by( 'id', $id_or_email->user_id );
} elseif ( is_string( $id_or_email ) ) {
$user = get_user_by( 'email', $id_or_email );
}
if ( $user ) {
$custom_avatar = get_user_meta( $user->ID, 'user-photo', true );
if ( ! empty( $custom_avatar ) ) {
$url = esc_url( $custom_avatar );
$avatar = sprintf(
'<img alt="%s" src="%s" class="avatar avatar-%d photo" height="%d" width="%d" />',
esc_attr( $alt ),
esc_url( $url ),
(int) $size,
(int) $size,
(int) $size
);
}
}
return $avatar;
}, 10, 6 );
The following line is used to override the user's photo:
$custom_avatar = get_user_meta( $user->ID, 'user-photo', true );
You'll want to replace this with the line of code that retrives the current user's profile photo URL. This will vary based on the plugin that you have installed.
Profile URLs
Our plugin has a setting for providing a URL pattern for profile URLs.
If your URL doesn't fit any of the available patterns, you can use a custom plugin to override the URL as follows:
<?php
/**
* Plugin Name: Create Minnit Chat Profile URL
* Description: Creates custom Minnit Chat profile URL
* Version: 1.0
* Author: Your Name
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Replace the profile URL with your own
*
* @param string $url The original URL.
* @param int $user_id The user ID.
* @return string The modified URL.
*/
function create_custom_minnit_chat_profile_url( $url, $user_id ) {
return "https://example.com/profile/test";
}
add_filter( 'minnit_chat_user_profile_url', 'create_custom_minnit_chat_profile_url', 10, 2 );
The function replaces the profile URL with a fixed URL each time (https://example.com/profile/test), so you'll need to modify the function to create the URL you want to use.
$user_id is the user ID that is making the request, so you can use this to pull data from WordPress or your database to create the URL.