How can I get the ownerguid of a current profile in another plugin?I did it by unregistering the default profile pagehandler and then registering a new profile pagehandler in my plugin. Is there any other easier/better way of achieving it?
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- William@williamdiaz
William - 0 likes
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- William@williamdiaz
William - 0 likes
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- William@williamdiaz
William - 0 likes
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- William@williamdiaz
William - 0 likes
- Kevin Jardine@kevin
Kevin Jardine - 0 likes
- William@williamdiaz
William - 0 likes
You must log in to post replies.get_input('username')
get_user_by_username()
won't that work?
No, it wont. I tried all possible things. Even tried elgg_get_page_owner_guid(), which is returning "0"/null
it would help to know what you are trying to do. are you creating a widget?
No, I want to show my user(Mr.X) a system message when they are looking at another user profile (Mr.Y). If I can get the Mr.Y guid, then it is easier. I can do this by overriding the profile page or a component of it. But I am trying to do it through the start.php itself. Any idea?
Hmmm. Quite strange. I can't get the guid either, even though the page_handler is setting the page_owner guid...
function profile_page_handler($page) {
if (isset($page[0])) {
$username = $page[0];
$user = get_user_by_username($username);
elgg_set_page_owner_guid($user->guid);
}
// short circuit if invalid or banned username
if (!$user || ($user->isBanned() && !elgg_is_admin_logged_in())) {
register_error(elgg_echo('profile:notfound'));
forward();
}
$action = NULL;
if (isset($page[1])) {
$action = $page[1];
}
if ($action == 'edit') {
// use the core profile edit page
$base_dir = elgg_get_root_path();
require "{$base_dir}pages/profile/edit.php";
return;
}
// main profile page
$params = array(
'content' => elgg_view('profile/wrapper'),
'num_columns' => 3,
);
$content = elgg_view_layout('widgets', $params);
$body = elgg_view_layout('one_column', array('content' => $content));
echo elgg_view_page($user->name, $body);
return true;
}
Yes, thats the problem. May be a bug?
Just checked. Not a bug.
You need to call page_owner from a view. You can't do it from the init.
That means, its a must for me to override the profile page view,right?. Isn't there any other option to get it by a plugin view hook or something?
Remember that there is a pagesetup event that is called immediately before views are rendered. You can register a hook for that and check the page context and owner there.
Kevin, tried the elgg_register_event_handler('pagesetup', 'system', 'getPvalue'); But still get nothing. Any idea?.