I am trying to provide 2 different add_widget_type statements to the widgets used on my site. The first will be loaded when the page owner is logged in and the other will be used when the user visits another users profile.
It seems that the widgets are being loaded before the page_owner data and/or loggedin_userid data become availible to do a comparasion.
eg. $po = 1
$uid = 1
if ($po == $uid)
add_widget_type
elseif ($po != $uid)
add_widget_type
Seems to work fine, But
$po = page_owner
$uid = get_loggedin_userid
if ($po == $uid)
add_widget_type
elseif ($po != $uid)
add_widget_type
Dose not work at all,,,,,,, So I'm thinking this is a timing issue.
Any Ideas?
Thanks for all the help
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.
oh ok thats why I couldn't find where profile was setting the context,,,,, I guess I need to figure out when the profile manager is done then set the context then
Oki...
I think you gonna have some mucho problems -- b/c the ProfileManager (and *all other PlugIns) are loaded / initialized by engine/start.php right in the beginning - hence yr "timing" issue ;-( by the time Profile/index.php comes in it might too late anyways.
really late is good I need the profile mangaer to declare the profile type before index sets the context because what I am trying to do is set the context according to which profile type is loaded,,,,
Im not understanding why the code picks this up for the admin and the real page owner but not when viewing someone elses page,,,,,, really confuseing,,,, I tryied adding an echo page_owner() to the code and it is getting their guid # on time to work but the if /else statement just dosent work banging my head on the desk lolz
i have studied the code some more... engine start.php loads messageboard start.php with add_widget_type - trying to grab the context -- but at that time profile index.php has not even woken up to set the context needed.. therefore i reckon this approach can never work for someone else's profile page.. walk away... and re-think different strategy ;-)
ok,,,,, but I still don't understand why this workds for the profile_p type of profiles
$p = page_owner_entity();
if (page_owner_entity()->custom_profile_type == 3)
set_context('profile_p');
elseif (page_owner_entity()->custom_profile_type == 6)
set_context('profile_b');
else
set_context(profile_p');
It works b/c Admin and Profile owner have permissions for access, not b/c profile type defn ;-( re-think !!
I will try to rethink but with the else statement on the end lets other users with the profile_p type profiles show up thats all I was saying
hehh.. as i said - it works not b/c of yr else code, but b/c admin and owner have oki doki permissions to see the content. your widgets need to consider different method of identifying profile owner and profile viewer to determine logic path to follow, b/c context will not make it work...;-( pity.
I wonder whether a different approach may be more manageable. You are modifying a bunch of plugins so that widget types are defined according to some criteria. Another possibility would be to remove widget types (undo the effects of add_widget_type()) that you don't want at the end. In other words, write a "last" plugin (last in the sense that it gets initialized after all the others), and in it's init, you can examine the profile type of the user and undefine widget types you want to filter out. I'd imagine that maintenance of your code down the road would be much easier with this approach.
- Previous
- 1
- 2
- 3
- Next
You must log in to post replies.