I’d like to access a DB table and render it in some data grid format using php on a dedicated wordpress page, accessible to members of a certain group. Is this at all possible with wordpress or is there another way to do so?
using wp 3.5 on linux system + mysql
thanks
You can create a simple plugin and either add a shortcode to run your php, or filter
the_content
and add a conditional check for your specific page and inject your DB output. This way your code will be independent of the theme and more portable. Use thewpdb
class to query any database /table.What do you mean by “page” here?
You can throw whatever PHP you want into a page template. If this is a more or less one-off thing, what you should probably do is use the conditional tags to just embed it.
If you mean you want to do this within content arbitrarily ie. through the post editor, that’s disallowed by core, but there are plugins that add the capability. The most recent one I’m aware of is Allow PHP in Posts and Pages, (there are others and you might want to look around) but this is something that’s generally advised against unless you absolutely trust every single person that might have access.
There are plugins that allow you to run php code in the post content. Here are a couple:
http://wordpress.org/extend/plugins/php-code-for-posts/
http://wordpress.org/extend/plugins/allow-php-in-posts-and-pages/