last day (14 days later) » 

3:29 PM
0
Q: why this php global doesn't echo in Wordpress plugin

Tomasz GolinskiI'm new to PHP and I'm not sure why this doesn't work. I have done everything this page said http://php.net/manual/en/language.variables.scope.php (example #1 Using global)... Why is it not working? it's frustrating. This is a first attempt on wordpress plugins. First file contains: function pp...

 
hmmm no idea why it doesn't show me anything. Does that matter that it's inside wordpress as a plugin?
 
Try $phost = 'Hello world'; see if that works. If it does, then it could have something to do with your settings.
 
@Fred-ii- I tried with few different variables.. and nothing shows.. although when I just type echo "text" it shows that
 
Try a different method $phost = 'localhost'; function getForumAccounts(){ global $phost; return $phost; } echo getForumAccounts();
Also, are you attempting to run the code from an include/require or as a standalone?
 
I just tried the 2nd method, didn't show anything either... this is a simple plugin in Wordpress which should just echo a variable. When I type echo 'test'; I can see that.. however if I use global variable, it's empty..
I will update my code, to show all I have
 
3:29 PM
@TomaszGolinski Edit your question to mention about you're using it in Wordpress and as a plugin. I did not vote to close, but will vote to reopen if you make the appropriate change to your question. I have added the relevant Wordpress tag to the question though.
 
@Fred-ii- ok ty, done... I didn't mention that was in wordpress because I thought it didn't matter
 
@TomaszGolinski Did you make the change in Wordpress plugin setting to include it as part of the site's structure? It's probably just some silly little setting somewhere.
 
@Fred-ii- just added some more details how I made the plugin.
I don't think I changed any core wordpress stuff tbh.
 
I'm no Wordpress guru, but I do know that you need to install the plugin via the dashboard. Google "how to install Wordpress plugin".
 
I installed the plugin and activated. It's visible in my admin bar as well as I can see the contents of sa-admin.php only not those from the functions described here. How do I get the thread reopened?
 
3:29 PM
hi
thought I would move this to chat
 
thanks, and sorry to be a pain in butt
 
not a problem and you're welcome.
as for reopening the question, there is 2 votes now, mine and another. Give it some time, others will pick up on the reopen
 
is there anything specific you need me to show you?
 
as far as your code goes, I couldn't say because I do not know enough about Wordpress to help you any further, which is why I added the tag and asked you to include the info about you're wanting to use in with Wordpress.
I see the pp_sa_search() function, you may need to call that function, just as you did in your plugin.
hard for me to say
 
I think this thing calls the function add_menu_page('Shadow Accounts Search', 'Shadow Accounts', 'manage_options', 'shadow_accounts', 'pp_sa_search');
at least one of the tutorials told that
its an in-build wp function
 
3:36 PM
ok, well like I said, I won't be able to help any further. I should have learned Wordpress a long time ago lol! There are just too many things about it that I don't like, which is why I hard code everything myself.
 
I'm a front-end developer, and I decided to go into back end, PHP and WP stuff... and it's much worse than I imagined lol
 
I can imagine. I got into WP a bit, but didn't go any further. I like the fact that I can control all my SQL/PHP and if something goes wrong, I'll know exactly where to go to find the potential bug.
I've been in SQL for just about a year now, but PHP for about 4-5. HTML/CSS for 20 yrs.
including graphics
 
yeah I just got asked by a friend to do a simple plugin to find 'shadow accounts' (accounts which are not linked between WP and phpBB) so I wanted to help. I just wanted to get list of accounts from wp then from phpbb and list only those which are not in both systems.. simple enough.. but I need to access globals in my script to do it...
 
I understand. Well, I checked your question again, it's up to 4 votes to reopen. Just one more vote and it will be reopened.
 
and I said, yeah simple, i can do it. and I'm stuck on this issue for like 4 hours. Tried to google but all I can find is exactly what I have done.
someone gave an answer which kind of makes sense
 
3:43 PM
4 hours isn't bad lol try 4 "days"! yep... that's happened to me 2-3 times where I had to figure something out in something I either wanted to build or had a problem with, so I know how it feels to spend a lot of time with no concrete results.
I have a very hard head lol
 
the annoying thing is, this is so easy problem that I most likely overthink and try to do too much to fix it xD
 
yeah, it could be something very minor. Even a simple missing period can put a damper on your day. Hey.. your question's been reopened :)
 
4 days, I would kick it and do something else haha
cool thanks :)
 
I almost gave in "once" about 4 months ago where I was going to ask a question on Stack, but I figured it out finally.
you're welcome Tomasz
I will delete my comments in your question and delete yours to me so we can clear your question's comment area.
 
ok that's fine, and thanks for your help once again, i will try to figure it out from the last commend from Boann
 
3:48 PM
I have deleted my comments to you. Delete yours to me, it will make some room. Also Boann has left a comment which may prove to be useful.
Ok Tomasz, I hope you find the solution, cheers mate :)
You: how else can I pass them into that function? - pass the variables in the function. For example function($var1,$var2,$var3)
 

last day (14 days later) »