Using WordPress ‘myblogs_allblogs_options’ PHP action

The myblogs_allblogs_options WordPress PHP action fires before the sites list on the My Sites screen.

Usage

add_action('myblogs_allblogs_options', 'your_custom_function');
function your_custom_function() {
    // your custom code here
}

Parameters

  • None

More information

See WordPress Developer Resources: myblogs_allblogs_options

Examples

Add a custom message before the sites list

Display a custom message before the list of sites on the My Sites screen.

add_action('myblogs_allblogs_options', 'add_custom_message');
function add_custom_message() {
    echo '**Important:** Check your site statistics regularly.';
}

Add a search box for filtering sites

Add a search box to help users filter sites quickly.

add_action('myblogs_allblogs_options', 'add_search_box');
function add_search_box() {
    echo '<input type="text" placeholder="Search site...">';
}

Add a button to create a new site

Add a button for users to easily create a new site from the My Sites screen.

add_action('myblogs_allblogs_options', 'add_new_site_button');
function add_new_site_button() {
    echo '<a href="/wp-admin/network/site-new.php" class="button">Add New Site</a>';
}

Display the total number of sites

Show the total number of sites a user has on the My Sites screen.

add_action('myblogs_allblogs_options', 'display_total_sites');
function display_total_sites() {
    $user_id = get_current_user_id();
    $user_blogs = get_blogs_of_user($user_id);
    echo 'Total Sites: ' . count($user_blogs);
}

Add a custom CSS class to the My Sites list

Inject a custom CSS class to the sites list container for further styling.

add_action('myblogs_allblogs_options', 'add_custom_class');
function add_custom_class() {
    echo '<style>.my-sites-list { background-color: #f5f5f5; }</style>';
}