Wordpress Themes - WP Forum at BFA
Click Here To DONATE! Support the theme development, get more attention and additional benefits based on your donation level. Your forum name will be highlighted.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Plugins & Atahualpa »

[SOLVED] global variables


Build custom WP THEMES, without
coding.
Click here for THEMEFRAME

From the author of Atahualpa, the #1 most
downloaded (700,000+) theme @ wordpress.org
  #1  
Old Apr 11, 2011, 03:03 AM
todo1979
 
8 posts · Apr 2011
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.
  #2  
Old Apr 11, 2011, 03:52 AM
juggledad's Avatar
juggledad
 
19,975 posts · Mar 2009
OSX 10.6.8/10.7.3 WP 2.8.x/2.9.x/3.x Atahualpa 3.5.x/3.7.x Safari 5.x Firefox 11 XP
Try adding
HTML Code:
Global $eu_slug;
  #3  
Old Apr 11, 2011, 02:25 PM
todo1979
 
8 posts · Apr 2011
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....
  #4  
Old Apr 11, 2011, 02:51 PM
STB
 
762 posts · Apr 2010
If you cant edit php.ini to enable globals, you would need to use $_GET and $_POST.

Havent delved into this before, but seems well documented:
http://www.google.com/#&q=php+global...4_GET+%24_POST
  #5  
Old Apr 12, 2011, 06:47 AM
todo1979
 
8 posts · Apr 2011
No, I can't access php.ini
I just can't figure out why the variable is lost
  #6  
Old Apr 12, 2011, 07:46 AM
juggledad's Avatar
juggledad
 
19,975 posts · Mar 2009
OSX 10.6.8/10.7.3 WP 2.8.x/2.9.x/3.x Atahualpa 3.5.x/3.7.x Safari 5.x Firefox 11 XP
Contact your host and get them to turn them on. If they won't help you, I'd move hosts.
  #7  
Old Apr 12, 2011, 10:16 AM
todo1979
 
8 posts · Apr 2011
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
  #8  
Old Apr 13, 2011, 02:00 AM
todo1979
 
8 posts · Apr 2011
Fixed, thank you so very much....

Bookmarks

Tags
global variables, todo1979

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
FR: Add variables to the paths to images, headers, logo, favicon, etc. interfasys Atahualpa 3 Wordpress theme 0 Jan 22, 2011 11:58 AM
[SOLVED] Notices on undefined indexes, variables and deprecated functions Knut Sparhell New Versions, & Updating 1 Jan 3, 2011 08:07 AM
Can't get a second row to enter HTML variables Thomas Sidebars & Widgets 18 May 16, 2010 09:59 AM
Accessing PHP variables after header sent out twola Sidebars & Widgets 1 Oct 2, 2009 11:24 AM


All times are GMT -6. The time now is 03:26 AM.


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