Would it be also be possible to get the default value from a Profile2-userprofile?
I think that people who want to make use of the default filtering based on what a user sets in his profile, will most of the time will use the profile2-module for more advanced profiling options.

Originally suggested by Ingmar.

CommentFileSizeAuthor
#19 profile2 tabs.jpg29.81 KBrdeboer

Comments

Ingmar’s picture

What's your opinion on this Rik, would it be difficult to develop? I remember you've developed the 'take default from normal user' very fast.

rdeboer’s picture

Should be fairly straightforward. But have no time for at least two weeks.
Patches welcome!
Rik

rdeboer’s picture

OMG... that was April when I said no time for two weeks.... It dropped off my radar....
Haven't given up.... It's still in the back of my mind... sorry.......

Ingmar’s picture

hehe:) Time flies when your having fun (I hope). Would still be handy.

rdeboer’s picture

It's back on the shortlist!
Rik

rdeboer’s picture

Assigned: Unassigned » rdeboer
Status: Active » Fixed

Done and checked in.

Both any number of profile2 user profiles and the core user account profile are scanned upon login for any global filter field values. You may mix the two.
If a global filter field appears on both a profile2 profile AND the core user profile, then the profile2 field takes precedence.

See latest 7.x-1.x-dev (17 Sept 2012 or later).

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

delvalle’s picture

Thanks a lot! I was also looking for this feature. Now I'm starting to implement it and I have two questions:

1) Using this new feature, I will only apply views filters based on the selections in the user profiles (Profile2 in my case), without using any Global Filter block or cache features in my site.
I'm not sure, but I think Session Cache API is not used anymore in this use case, so maybe it could be possible to remove it as a required dependency of Global Filter module. If this is not possible, I would like to know what Session Cache storage option is more recommended for my case (I don't need any cache storage, but it's mandatory to select one option if the Session Cache module is enabled).

2) Now the changes in user profiles are evaluated only at login, so the users must logout and login again in order to have the changes applied to the corresponding filters and views (not very user friendly...). There is some way to apply changes made in user profiles without forcing the users to logout and login again?

Thanks again RdeBoer, this module rocks! :)

rdeboer’s picture

Status: Closed (fixed) » Active

Hi Xiwino
1) Yes technically speaking if you only want the global filter values to come from the user profile, then Global Filter does not need to depend on Session Cache API. But it's only a small module, it does not do much. In your case I would probably pick the default $_SESSION, or cookie if you want the selection to continue after logout.

2) Yes changes to the profile are only evaluated upon login. That's how it was designed. After that the filter is changed wherever you put the global filter block. In your case you want people to go to their user profile every time they want to change the global filter, right? Why not put the global filter block on the profile page? Wouldn't that almost achieve the same effect?

Rik

delvalle’s picture

Status: Active » Fixed

Thanks Rik!
I will pick the $_SESSION and try the solution of putting the global filter block on the profile page (surely not my ideal solution, but could do the trick for the moment). Fixed for me...

rdeboer’s picture

Thinking about this more.... if the global filter was set on Submit of the profile (as well as upon login), would that satisfy your use-case. As you would not need to position any Global Filter blocks anywhere, right?

delvalle’s picture

Yes, setting the global filters on submit/update of profiles would be perfect for my use-case and would eliminate the need for any Global Filter blocks.

rdeboer’s picture

Category: support » feature

Not everyone wants it this way though.
Flagging as feature request (with option to switch this behaviour on or off).

rdeboer’s picture

@xiwino

Checked in two optional features, which can be switched on or off independently on the Global Filter configuration page.
o Set global filters according to the user profile upon login
o Set global filters according to the user profile upon submit

That should satisfy your use-case, right?

Please test 7.x-1.x-dev (18 Dec 2012 or later), as I haven't had much time to do that yet.

Rik

delvalle’s picture

Thanks Rik,

That would satisfy my use-case, but I've done some quick-testing of the dev version and the "upon submit" option doesn't seem to work.

In module configuration I've checked both options (upon login and upon submit) and the login option still works OK but submitting the user profile doesn't make any change in my global filters.

I've run update.php and also cleared all caches, but it still doesn't seem to do anything. I want to use Profile2, but I've also tested with core profile and doesn't work either upon submit (it works correctly upon login in both cases).

rdeboer’s picture

There was a bug in setting the Global Filters from the core profile, which I've just fixed and checked in. Profile2 profiles worked for me though. For more info enter your user name or names on the GLobal Filter config page, in this box: "Show Global Filter informational messages during execution". For example "admin,anon".
Then change user profile fields and see what it sets when you Save.

Use 7.x-1.x-dev (19-Dec or later).

You do indeed need to clear caches after installing the latest version as it's a new form submit handler.

delvalle’s picture

OK, the results of my tests using last dev (with messages during execution activated):

1) Profile2 changes with the option "Provide a separate page for editing profiles" DESELECTED works perfectly (changes apply when saved and also upon login). After saving the messages show as expected:

Global Filter field_ambito: setting value from user profile...
Global Filter field_ambito: changing from 8 to 9
Global Filter field_mercado: setting value from user profile...
Global Filter field_mercado: changing from 11 to 10

2) Profile2 changes with the option "Provide a separate page for editing profiles" SELECTED only applies upon login (no messages or changes in global filters when saved). NOTE: The goal of this option is to make the Profile2 page available on /profile-examplename/uid instead of inside the profile (/user/uid/edit/examplename)

3) Core profile doesn´t seem to work different to previous dev: Changes only applies upon login (no messages or changes in global filters are showed when saved).

My desired configuration is 2): Profile2 with the separate page activated (having that separate page is the only reason why I want to use Profile2).

rdeboer’s picture

Oops.... completely forgot about the Profile2 option for separate page... no wonder it's not working!

Will investigate.

Suprised though about core profile... believe I have that working on my system. We're talking about the Account tab at user/1/edit, right?

On my system all core and Profile2 user profile fields get saved into their associated Global Filters, regardless of whether you press Save on the Account tab, the Main Profile tab (default Profile2 tab) or any additional Profile2 tabs.

Naturally only those profile fields that indeed appear as drivers for global filters will be set and show up in the info messages.

Rik

rdeboer’s picture

StatusFileSize
new29.81 KB

Core and Profile2 user profiles
Screenshot of the user/1/edit/main page, i.e. default Profile2 user profile page, showing a field that is used as a Global Filter driver.
Also showing core's user profile (Account tab) and another Profile2 user profile page, "Profile2 Rik".

rdeboer’s picture

Checked in code to make above work for the case where "Provide a separate page for editing profiles" is ticked (ie Profile2 Pages submodule enabled).

Available in 7.x-1.x-dev (21 Dec 2012 or later).

delvalle’s picture

All right, now it's working perfectly for the 3 options! (core profile and Profile2 with and without separate page).

Maybe the core profile problem was caused by something in my configuration or set of installed modules (although that would be strange, because I think I haven't done any change since the test with the previous dev version). I've been thinking about a possible explanation without any success... Anyway, now it's working! :)

Thanks for all your help, Rik!

rdeboer’s picture

Status: Fixed » Closed (fixed)

Ok then we can well and truly close this!
Merry Xmas.

Ingmar’s picture

I suggested the features to take default from Profile2 and have been following this topic ever since then. The new features will definitely come in handy for me as well. Thanks Rik for the work you put into this!

rdeboer’s picture

You're welcome Ingmar! Thanks for you initial suggestions that got this improvement going.

rdeboer’s picture

Issue summary: View changes

Added link to Ingmar's profile