Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Buddypress Member Profile URL with User ID instead of Username

View gist:5503865
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
<?php
function bp_get_user_domain_with_id( $domain, $user_id, $user_nicename = false, $user_login = false ) {
if ( empty( $user_id ) )
return;
if( isset($user_nicename) )
$user_nicename = bp_core_get_username($user_id);
//if ( !$domain = wp_cache_get( 'bp_user_domain_' . $user_id, 'bp' ) ) {
$after_domain = bp_get_members_root_slug() . '/' . $user_id;
$domain = trailingslashit( bp_get_root_domain() . '/' . $after_domain );
$domain = apply_filters( 'bp_core_get_user_domain_pre_cache', $domain, $user_id, $user_nicename, $user_login );
// Cache the link
if ( !empty( $domain ) ) {
wp_cache_set( 'bp_user_domain_' . $user_id, $domain, 'bp' );
}
//}
return $domain;
}
add_filter('bp_core_get_user_domain', 'bp_get_user_domain_with_id', 10, 4);
function bp_get_userid_with_id($userid, $username){
//if the username is an userid ?
if(ctype_digit($username)){
// check if a user with userid equal to $username exist
$aux = get_userdata( $username );
if( get_userdata( $username ) )
$userid = $username;
}
return $userid;
}
add_filter('bp_core_get_userid', 'bp_get_userid_with_id', 10, 2);
//add_filter('bp_core_get_userid_from_nicename', 'bp_get_userid_with_ideddde',10, 1);
// bp_core_get_userid_from_nicename filter havn't the $username in param :( so i was
// add filter to bp_is_username_compatibility_mode to force the excution of bp_core_get_userid
// *** check line 261 of bp-core-catchuri.php ***
function bp_is_username_compatibility_mode_always_true(){
return true;
}
add_filter('bp_is_username_compatibility_mode', 'bp_is_username_compatibility_mode_always_true');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.