fromscratch
Veteran
Just Getting Started
Member Likes (0)
I'm creating a wordpress multisite plugin for a new app that's coming out and I'm having trouble getting things to work correctly.
To be more specific, I need to display code above the closing </body> tag of each site. I got everything to work, the only problem is when I created an options page. I added a field to add the account ID number and then network activated the plugin. Everything worked great except that it only updated the current site I was on (which was the admin site). All the other sites didn't have the account ID applied.
How do I set up the options page to place the ID on ALL of the websites, not just one?
Responses (8)
Support Chimp (joined March 2010) Likes (0)
Hi fromscratch.
When you say account ID, do you mean the site ID, the UID.
You might want to take a look at:
http://codex.wordpress.org/WPMU_Global_Variables
Get User data:
http://codex.wordpress.org/Function_Reference/get_userdata
and:
http://codex.wordpress.org/Function_Reference/get_currentuserinfo
The last one as you will see gets the current users information and creates a global variable $current_user and the UID $user_ID.
I hope this helps. :-)
Member (joined February 2011) Likes (0)
Yeah I have all of that information, I should've been a bit more clear.
When I said Account ID that's just the name of the field I made in the options page.
When I'm logged in as a super admin, I go to the settings page and input the string I'd like to use (or in this case, the account ID). I save it, it works on the current site I'm on but it doesn't save to all the sites.
The plugin itself is network activated but it's only saving options to the current site. Does that make more sense?
Member (joined February 2011) Likes (0)
Sorry, forgot to click the "Not Resolved" button.
Support Chimp (joined March 2010) Likes (0)
I think it makes sense. So the account ID is something entered by the user or by you the admin, rather than the UID dynamically and automatically?
What function you are using to save the data to your DB?
I'm sure you have but you could start by looking here if you haven't already:
http://codex.wordpress.org/Function_Reference/update_option
http://codex.wordpress.org/Function_Reference/add_option
The following tutorial might also help:
http://net.tutsplus.com/tutorials/wordpress/creating-a-custom-wordpress-plugin-from-scratch/
Hope this helps. :-)
Member (joined February 2011) Likes (0)
I'm actually using this amazing plugin as a base:
http://wordpress.org/extend/plugins/plugin-options-starter-kit/
And it works great, but same as before, when I update, it only updates the site, not the network.
Is there a way to have the settings on the super admin page and when the options are saved it stays saved on all the websites?
Member (joined February 2011) Likes (0)
I'm actually not saving it in the DB (still not 100% familiar with that) so it's just a variable I believe.
Support Chimp (joined March 2010) Likes (0)
Hey
Where is your variable storing the data to be accessed elsewhere apart from local scope on the given page?
If you read through the article I linked to it should guide you through using the DB.
Take care.
Member (joined April 2009) Likes (0)
Hiya,
As we haven't heard back from you we're going to assume the problem was sorted out and mark this ticket as resolved.
If it wasn't resolved, or you have any more questions related to this thread please feel free to post them below and tick the 'Mark as Not Resolved (re-open)' box below the post area (or else we'll miss it!)
Otherwise, thanks for using the forums, and for being a member of WPMU DEV, it's a pleasure to help you out and we look forward to being of assistance in the future.
Thanks
WordPress Questions?
We've got answers!
Find out more »