Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Plugins & Atahualpa (http://forum.bytesforall.com/forumdisplay.php?f=16)
-   -   [SOLVED] global variables (http://forum.bytesforall.com/showthread.php?t=13733)

todo1979 Apr 11, 2011 03:03 AM

[SOLVED] global variables
 
Hi to all,
maybe someone can help my with this one. On my local wamp server I have global variables activated and I can use sessions for one plugin I modified. The plugin in question is restrict-categories and based from which category (when a category is displayed I added a link to post-new.php) the user wants to post a new post it should give him the option to only check one category the post will be added to (basically all other categories are hidden except the one that the post will belong to).
In atahualpa center-column I added this:

session_start();
$eu_scattitle = single_cat_title("", false);
$eu_scatid = get_cat_ID($eu_scattitle);
$eu_curr_cat = get_category($eu_scatid);
$eu_slug=$eu_curr_cat->category_nicename;
$_SESSION['eu_slug'] = $eu_slug; //this is what I need to be stored and later use in restrict-categories

Now, because globals are disabled, the session variable is lost when the execution enters into another .php file.

Is there a way to declare the variable I need inside the center-column (or in one .php file that belongs to atahualpa) and later to be available in the restrict-categories function?... like global $wpdb; or something?

Thank you.

juggledad Apr 11, 2011 03:52 AM

Try adding
HTML Code:

Global $eu_slug;

todo1979 Apr 11, 2011 02:25 PM

It's not working,
as soon as another .php file starts execution, the variable is lost.... don't know what to do.... this happens on the site I have hosted by a company.... on my local computer, session variables work but....

todo1979 Apr 12, 2011 06:47 AM

No, I can't access php.ini
I just can't figure out why the variable is lost

juggledad Apr 12, 2011 07:46 AM

Contact your host and get them to turn them on. If they won't help you, I'd move hosts.

todo1979 Apr 12, 2011 10:16 AM

Yes I think that is what I'll do, thank you. However, I understood that turning global variables on is quite risky, even if the entire platform only uses 1 session variable, will I have any hacker problems?
Thanks

todo1979 Apr 13, 2011 02:00 AM

Fixed, thank you so very much.... :)


All times are GMT -6. The time now is 04:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.