How to manage different admin notices for different blogs?

i am trying to create plugin that can manage different admin notices or any other information for different blogs.

for example: i have in my multisite network 50 blogs. i want to select some blog and show in the plugin page some admin notice or any other information like image or whatever…

so my question is how to create and manage all the notices in the /wp-admin/network/ and then show all the admin notices or any other information in the plugin page on each blog with the only information that belong to this blog id.

what i have done so far:

get list of active blogs:

$blogs = $wpdb->get_results( "SELECT * FROM $wpdb->blogs WHERE public = 1" );

foreach($blogs as $blog)
{
//the code to list or wrap all blogs
}

now i need some good way to sort all the blogs so i can select the one i want to add some admin notice for this blog.

i think first on the drop menu but when i will have many blogs it will not be good solusion. so what do you think?

then after i will select the blog, i trying to figure out how to manage all this admin notice for each blog?

and the last is to show all the saved information in the plugin page (this will be not so hard to make after all will work)

so guys what do you think is the right way to make this work?

Thanks

  • Tyler Postle
    • CGO

    Hey Ruslan,

    Hope you’re doing well today and thanks for your question!

    What sort of notices are you planning on showing? Just notices about the plugins list to communicate with your clients?

    Are you going to create these notices on the spot after selecting the blog?

    Just wanting to get a better idea of what exactly you want to happen here :slight_smile:

    It sounds like it will require a good amount of custom code to achieve unless I am mistaken.

    Look forward to hearing back Ruslan!

    All the best,

    Tyler

  • Ruslan
    • The Incredible Code Injector

    Hi @tyler Postle,

    i just want to show different info to different blog admins

    for example:

    i manage ppc for blog admins. so i want to upload pic of the campaign so each blog will see his own campaign.

    or if i need to write some note to some blog admin so i want to have this option.

    you can do many things with this addon.

  • aristath
    • Recruit

    Hello there @ruslan, I hope you’re well today!

    In WordPress you almost never should query the db directly… most of the time there are functions that already do what you need!

    In your case, you can use the wp_get_sites function: http://codex.wordpress.org/Function_Reference/wp_get_sites

    As for managing who the info goes to, I would suggest you do not add a list of blogs etc, but instead use a simple textfield. This way you can simply add a comma-separated array of blog IDs there.

    You will then be able to use something like this to convert it to an array:

    $settings_array = explode( ',', $my_settings );

    I hope that helps!

    Cheers,

    Ari.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.