filters – Redirect to Multisite site 2 if site 1 has a setting

Question

On my Multisite, there is a custom setting that indicates whether the site is disabled. It uses get_blog_option($id, 'deleted') flag that is set if the blog is marked for deletion (essentially, the blog is ‘inactive’).

That flag doesn’t seem to be used if you load that site. So I need to intercept the Site 2 load if that flag is set (if get_blog_option(2,'deleted') === '1'), and wp_redirect to a specific page on Site 1.

I believe I can do this with the wp_loaded filter. But is that the proper filter to use? I need the theme code to load (since the test will be in the Child Theme’s functions.php file; I don’t need it to be in a separate plugin), but the blog content needs to switch to Site 1.

It’s not clear to me from the docs that using the wp_loaded filter is the proper spot to switch to Site 1. Is ‘init‘ filter better?

What sequence should I use to allow the ‘test’ in the Child Theme functions.php to switch to another blog if needed?

Related to this is that if you ‘inactive’ a blog (via the Sites screen), why does that blog still load on the front end?

0
Rick Hellewell 2 months 2023-01-30T18:26:06-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse