WordPress’s is_plugin_active_for_network function not working for multisites

You need to check that when you are activating the plugin. WordPress will send a Boolean flag to let your function know that this is a network wide activation.

register_activation_hook( __FILE__, 'activate' );

function activate( $network_wide ) {

    // $network_wide will be TRUE if activation is network wide
    if ( $network_wide  ) {

        ... Do Stuff ...

    }

    ...

}

error code: 523