mycred_parse_tags_user

Codex / mycred/log / Filters / mycred_parse_tags_user

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

This filter lets you add support for custom user related template tags or override the default ones.

This filter is also used by for example the Rankings Add-on to add new custom template tags for rank names and logos.

Used By

Parameters

  • content (string)
    The content containing template tags.
    Remember to always return the content once you are done!
  • user (object)
    The user object.
    Note! If the user has been deleted you will only have access to $user->ID, $user->user_login and $user->display_name.
  • data (array|string)
    If parsing the myCRED Log, the data column is passed on here. Else it will contain an empty string.

Example

Add two new template tags %avatar_small% and %avatar_large%, which will return given users avatar either in a smaller version ( 32px by 32px ) or a larger version ( 64px by 64px ).

add_filter( 'mycred_parse_tags_user', 'my_custom_user_template_tags', 10, 3 );
function my_custom_user_template_tags( $content, $user, $data )
{
	$content = str_replace( '%avatar_small%', get_avatar( $user->ID, 32 ), $content );
	$content = str_replace( '%avatar_large%', get_avatar( $user->ID, 64 ), $content );
	return $content;
}

Add this code to your themes functions.php file

Last edited June 26, 2016