WordPress Filters and Hooks

iFlyChat Filters Implementation

To implement Wordpress filter in your module, you just need to add the filter definition of these filter in your main plugin file. Sample implementations are given below:

Note: These filters are supported from version >= 4.2.5

1: iflychat_get_username_filter - Assigns a username to a given user.

/**
 * Implements my_custom_get_username()
 * @params $user_name string 
 * @params $uid string 
 */
function my_custom_get_username($user_name,$uid){
  $user_name = 'SampleName';
  return $user_name;
}
add_filter('iflychat_get_username_filter','my_custom_get_username',10,2);

2: iflychat_get_user_avatar_url_filter() - Assigns a avatar url to the given user.

/**
 * Implements my_custom_get_user_avatar_url()
 * @params $user_avatar_url string 
 * @params $uid string 
 */
function my_custom_get_user_avatar_url($user_avatar_url,$uid){
  $user_avatar_url = 'http://sample-avatar-url';
  return $user_avatar_url;
}
add_filter('iflychat_get_user_avatar_url_filter','my_custom_get_user_avatar_url',10,2);

3: iflychat_get_user_profile_url_filter() - Assigns a profile url to a given user.

4: iflychat_get_user_roles_filter() - Assigns roles to a given user.

5: iflychat_get_user_groups_filter() - Assigns a group to a given user.

6: iflychat_get_user_friends_filter() - Assigns a relationship to a given user.

7: iflychat_check_access_filter() - Display chat to a limited set of users.

For reference - https://developer.wordpress.org/reference/functions/add_filter/

Last updated

Was this helpful?