mycred_users_profile_url

Codex / mycred/balance / Filters / mycred_users_profile_url

Navigation:

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

Description

This filter allows you to adjust what URL the %user_profile_url% and the %user_profile_link% template tags point to. By default, myCRED will use the username (urlencoded) combined with the WordPress author base as the URL but you can change this to anything using this filter.

Requires myCRED 1.3 or higher.

Used By

  • Class: myCRED_Settings Method: template_tags_user()

Parameters

  • url (string)
    The URL address.
  • user (object)
    The user object.

Examples

Example 1: Use a custom URL structure www.mysite.com/members/username/.

add_filter( 'mycred_users_profile_url', 'mycred_pro_adjust_user_profile_url', 10, 2 );
function mycred_pro_adjust_user_profile_url( $url, $user ) {

	// Adjust the URL
	$url = get_bloginfo( 'url' ) . '/members/' . urlencode( $user->user_nicename ) . '/';
	return $url;

}

Example 2: Replace empty spaces in the username with a hyphen.

add_filter( 'mycred_users_profile_url', 'mycred_pro_adjust_user_profile_url', 10, 2 );
function mycred_pro_adjust_user_profile_url( $url, $user ) {

	// Adjust the URL
	$username = str_replace( ' ', '-', $user->user_login );

	// Adjust the URL
	global $wp_rewrite;
	$url = get_bloginfo( 'url' ) . '/' . $wp_rewrite->author_base . '/' . $username . '/';
	return $url;

}

Last edited December 5, 2016