Member Profile URL with User ID instead of Username
-
Is it possible to set the urls of member profiles to
http://www.mydomain.com/members/username (or nicename)
to
http://www.mydomain.com/members/35223 (example user id #)
?
-
Check this out, for customizing labels and URLs: https://codex.buddypress.org/extending-buddypress/customizing-labels-messages-and-urls/
You can get the current logged in user id from here: https://codex.buddypress.org/developer-docs/the-bp-global/
check out the `$bp->loggedin_user object` section
I’d be more interested in the displayed_user object, but I’m not sure where to go from there. To globally change the profile slug not just for /members/ but for /members/[username] to /members/[user_id]. Any other suggestions?
Anyone?
@scylderon hi, have ??? solved this quest?
I am looking for a similar solution
Looking for same answer as well
Hi,
I was made a hack for that and it work partially!!
The code need more tests, all feeback’s are welcome.
Add this code to your functions.php
The problem is from js code who animate #whats-new-options div, he make a div 40px hight.
i find fix, i will fix the plugin by ading this code in js file
jQuery('#whats-new').off('focus'); jQuery('#whats-new').on('focus', function(){ jQuery("#whats-new-options").css('height','auto'); jQuery("form#whats-new-form textarea").animate({ height:'50px' }); jQuery("#aw-whats-new-submit").prop("disabled", false); });
Regarding the code on github, yes, that did partially fix it. Now all users can be found via their user id # rather than username.
/members/id #/
The only problem I see so far is that the code didnt update the activity feed. If you click a name for a user in the activity feed it is still trying to locate user the old way but the user icons on the newsfeed are correct and try to take you to user profile with their user id #.
So say for example:
James Gill wrote a new post, Gluten
The name James Gill is still trying to render the /members/username/ but not the /members/user id#/
but the rest of the site except activity feed appears to be working right now. only the icons on the activity feed try to render /members/user id#/
Yes @phatjay,
I think for the old activities, he dont update because the link of members and all content of activity is storeed in databse,
you try to post a new activity and see if the link is /members/id #/
thanks for feedback.
Ah, nice. Yep, the old activities save in the db. Now I am going to go in the db and just drop the old activities
Hi,
I would like to change the buddypress profile page url ‘/members /user_id’ from ‘/member /usersname’.https://gist.github.com/dzmounir/5503865
I tried to use above code on fanctions.php.
Profile page url has been changed as ‘/members/user_id’,but it was not displayed.————————————————————————————————–
Warning: Missing argument 2 for bp_get_userid_with_id() in /wp-content/themes/my-theme/functions.php on line 117Warning message appered from the following code.
function bp_get_userid_with_id($userid, $username){
//function bp_get_userid_with_id($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);————————————————————————————————–
I am sorry about the insufficient study in the buddypress’s hook,
please tell me how to change profile page url as ‘/members/user_id’ .
- The topic ‘Member Profile URL with User ID instead of Username’ is closed to new replies.