Support » Plugin: GiveWP - Donation Plugin and Fundraising Platform » Using Give_Payments_Query with switch_to_blog in multisite

  • Resolved pineapplejuice



    I’m setting up some custom shortcode functions in a multisite setup. I have 3 sites and want a shortcode to process and display massaged statistics of donations that were made across all the 3 sites.

    I basically use something like this:

    foreach( $blog_ids as $b ){
        switch_to_blog( $b->blog_id );
        $donations_obj = new Give_Payments_Query(
                            'give_forms' => $formIds,  //all give-forms IDs
                            'number'     => - 1,
                            'status'     => array( 'publish' ), 
                            'start_date'  => date("Y-m-d H:i:s", $start_date),
                            'end_date'      => date("Y-m-d H:i:s", $end_date)
        $donations = $donations_obj->get_payments();

    Unfortunately, complete payment info is only returned for the site you are currently on when calling the shortcode. Even though I see that the switch_to_blog does correctly change the db prefix, it seems that the Give_Payment Object for donations from the db table on other sites in multisite setup is missing almost all the info. Only id, post_date, post_status is there, all other details are missing, even form_id.

    Anyone have any suggestion on what I’m missing? I could off course just do my own wp db queries, but I’d really prefer just to use the give functions. I already suspect that it some singleton problem with when the plugin is loaded vs the shortcode executed…

    Any pointers would be appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Using Give_Payments_Query with switch_to_blog in multisite’ is closed to new replies.