By Jan Bergare on Wednesday, 26 June 2019
Posted in General Issues
Likes 0
Views 741
Votes 0
How can I obtain the user id of the profile I'm currently viewing (when it is not the logged in user's profile)?

I'm having the same issue in two places:

1) I want to place info from the currently viewed profile in the es-sidebar position of EasySocial (not the currently logged in user)
2) I want to place info from the currently viewed blogger in a separate module in the single blogger view of EasyBlog

Using php in a custom module, I figure it would be something like:


<?php
require_once(JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/easysocial.php');
$user = ES::user($id);
echo $user->getFieldValue( UNIQUEVALUE );
?>



...but how can I get the $id of currently displayed profile/blogger?

Thanks for any assisance!
Hey there,

I'm having the same issue in two places:

1) I want to place info from the currently viewed profile in the es-sidebar position of EasySocial (not the currently logged in user)
2) I want to place info from the currently viewed blogger in a separate module in the single blogger view of EasyBlog


If I understand correctly, you just want to retrieve the user id when you are viewing the user profile page on ES and you just want to retrieve the blogger id when you are viewing on the single blogger page.

If yes, you can use the following PHP code for it:

For EasyBlog:

require_once(JPATH_ADMINISTRATOR . '/components/com_easyblog/includes/easyblog.php');
$input = EB::request();

$view = $input->get('view', '', 'cmd');
$layout = $input->get('layout', '', 'cmd');

if ( $view == 'blogger' && $layout == 'listings' ) {
$id = $input->get('id', 0, 'int'); // if this is single blogger view page then retrieve blogger id

// you can place your info

}



For EasySocial:

require_once(JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/easysocial.php');
$input = ES::request();
$view = $input->get('view', '', 'cmd');

if ( $view == 'profile' ) {
$id = $input->get('id', 0, 'int'); // if this is user profile view page then retrieve user id

// you can place your info

}


Can you have a try and see how it goes?

EDITED
·
Wednesday, 26 June 2019 12:32
·
0 Likes
·
0 Votes
·
0 Comments
·
Works like a charm!

Thanks again for your amazing support.
·
Wednesday, 26 June 2019 16:33
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi there,

You are most welcome.

Just for your information, I have locked and marked this thread as resolved to avoid confusions in the future. Please start a new thread if you have any other issue in the future so it will be easier for us to manage your inquiries.

Thanks for understanding.
·
Wednesday, 26 June 2019 16:52
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post