Support » Networking WordPress » Inform php programs called from WP which site it is

  • We run a sailing school. A student selects a course from a menu, and WP (via a hyperlink) invokes a php progam in another part of our site) that displays the schedule for that course. He can then register for the course. The hyperlink contains the path to the php program to run, as well the course name and a couple of other things

    We now want to run a school at another location, with a different set of courses and schedules. I have multisite running on a test system, with two sites … the original, and the new one.Both sites look the same, with minor differences. The php programs that get called need to know which site is running, so they use the proper database for that site..

    Is there any way WP Multisite can pass this information on, perhaps via a cookie, that the php program could read? I already have written a plugin that sets a cookie via a hook. If there was a hook that could be invoked when one of the sites started up, I could easily set a cookie that the php program could read.

    One option is to add a site parameter to each hyperlink, but that requires changing a LOT of hyperlinks, and is an error-prone process.

    Any suggestions would be appreciated. MultiSite appears to be exactly what we need.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Maybe just use get_current_blog_id() to identify which site you’re on currently, and send it in a URL parameter to the PHP function/set a cookie?

    If there was a hook that could be invoked when one of the sites started up

    There are many hooks you can use for this, probably ‘wp_loaded’ would be fine.

    function do_something_with_current_blog_id() {
        $blog_id = get_current_blog_id();
        // Do something to form your link for the PHP script 
    add_action( 'wp_loaded', 'do_something_with_current_blog_id' );

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.