Skip to:
Content
Pages
Categories
Search
Top
Bottom

about globals, sessions & cookies.


  • grosbouff
    Participant

    @grosbouff

    Hello !

    I have a little question here.

    I’m building my own component and it will have some filters possibles, eg. to filters the content by “days old” (days_active).

    When running a query to show the items, the script would check :

    -if the user set a days_active filter

    –if not, if the admin set a days_active filter.

    My question is:

    How must I call the datas ?

    I have set all the admin filters in

    $bp->mycomponent->options.

    So to get the admin filter, I would get $bp->mycomponent->options[‘days_active’].

    It’s in the global so here it’s rather ok.

    Now for the user…

    get_usermeta($user_id,’mycomponent_days_active).

    But if I run this each time, it will slow my component…

    So where to store it ?

    Is it a good idea to store that in sessions ? It could work both for logged in and non logged in users…

    OR maybe in sessions for visitors and elsewhere for members ?

    Thanks to give me some advices !

Viewing 3 replies - 1 through 3 (of 3 total)
  • get_usermeta() will cache multiple calls on the same page, so you should be fine.


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    grosbouff, so you have a set of administrative default filter settings, and you’re going to let users set their own filters and customize existing queries? Is that right?

    If so, then Andy is of course correct. It won’t need this in a session because once the plugin is loaded via buddypress, the info is available without any additional queries to the db once the data is acquired for the first time. It shouldn’t slow anything down, other than the initial gathering of the data.


    grosbouff
    Participant

    @grosbouff

    Hi John;

    Yes this is it.

    So I don’t need to store that in sessions ? I don’t need to do anything, except get_usermeta when I need to ?

    Nice !

    “the info is available without any additional queries to the db once the data is acquired for the first time”

    …only on the page shown or for all plugin pages ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘about globals, sessions & cookies.’ is closed to new replies.
Skip to toolbar