Skip to Content Skip to Menu

Hide username in URL of Profile-Link

9 years 7 months ago #261297 by avateamcom
Hide username in URL of Profile-Link was created by avateamcom
Using: CB 2.0.7, GroupJive, Kunena, DJClassifieds

Hello everybody,

I don't want to let the users see the other users usernames, they only should see the real named. When clicking on another users name, the username is shown in the url of the profile-page. is there a possibility to change this behaviour of cb to link to the real names instead?

Now: domain.xy/cb-profile/userprofile/smurf

I want: domain.xy/cb-profile/userprofile/michael%20smith

Thanks for your help! :)

Best regards,
-Stefan

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
9 years 7 months ago #261325 by krileon
Replied by krileon on topic Hide username in URL of Profile-Link
You can't use real names. Real names are not unique. What happens when 2 people have the same name? You wouldn't be able to reach the correct profile. It has to be unique, which username is. At any rate the only way to alter the SEF behavior is to modify CBs router.php found at the below location.

components/com_comprofiler/router.php


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

9 years 7 months ago #261361 by avateamcom
Replied by avateamcom on topic Hide username in URL of Profile-Link
Hi Kyle,

thank you for your quick answer!

Yes, of course, only real name would be a bad idea.. :)
DJ Classifieds uses a combination of user-id and realname like:

.../804-peter-fox

Can you give me a hint, where and how I can change the comprofilerBuildRoute-function that the url will be generated like that?

Thank you in advance!!
Best greetings,
Stefan

Please Log in or Create an account to join the conversation.

9 years 7 months ago - 9 years 7 months ago #261364 by avateamcom
Replied by avateamcom on topic Hide username in URL of Profile-Link
Well, I got it on my own the following way:

In comprofilerBuildRoute I added the following code before segments[]=... and changed that line too:
Code:
$sqluid = 'SELECT' . $database->quoteName( 'id' ) ."\n FROM " . $database->quoteName( '#__users' ) ."\n WHERE " . $database->quoteName( 'username' ) . " = '".$query['user'] . "'"; $database->setQuery( $sqluid, 0, 1 ); $userid = $database->loadResult(); $segments[] = rawurlencode( str_replace( '.', ',', $userid ) ). "-cn-" .$query['user'];

In comprofilerParseRoute I added the following line at first in the if-block:
Code:
list($userid, $user) = explode("-cn-", str_replace( array( ':', ',' ), array( '-', '.' ), $segments[1] ));
and changed the line
Code:
$vars['user'] = (int) $user;

simply into the following:
Code:
if ( $userid == (int) $user ) { $vars['user'] = (int) $user; }

Is that enough or do I have to change some more?
Is it okay just to use the $userid-variable (added by myself) of the first function in the second?

Thank you for your help!!

Best regards,
Stefan
Last edit: 9 years 7 months ago by avateamcom. Reason: I forgot a line.. ;)

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
9 years 7 months ago - 9 years 7 months ago #261419 by krileon
Replied by krileon on topic Hide username in URL of Profile-Link
Typically you'd do ID:ALIAS which Joomla will automatically convert to ID-ALIAS and pull the ID off for the query matching. The userlist rewriting does this already so that could be a good example to use.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 9 years 7 months ago by krileon.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum