The ms_user_list_site_actions WordPress PHP filter allows you to modify the action links displayed next to the sites a user belongs to in the Network Admin Users list table.
Usage
add_filter('ms_user_list_site_actions', 'your_custom_function', 10, 2); function your_custom_function($actions, $userblog_id) { // your custom code here return $actions; }
Parameters
- $actions (string[]): An array of action links to be displayed. Default ‘Edit’, ‘View’.
- $userblog_id (int): The site ID.
More information
See WordPress Developer Resources: ms_user_list_site_actions
Examples
Add a custom action link
Add a custom action link to visit the site’s dashboard:
add_filter('ms_user_list_site_actions', 'add_dashboard_link', 10, 2); function add_dashboard_link($actions, $userblog_id) { $actions['dashboard'] = '<a href="' . get_admin_url($userblog_id) . '">Dashboard</a>'; return $actions; }
Remove the “Edit” action link
Remove the “Edit” action link from the list of actions:
add_filter('ms_user_list_site_actions', 'remove_edit_action', 10, 2); function remove_edit_action($actions, $userblog_id) { unset($actions['edit']); return $actions; }
Change the “View” action link text
Change the “View” action link text to “Visit Site”:
add_filter('ms_user_list_site_actions', 'change_view_text', 10, 2); function change_view_text($actions, $userblog_id) { $actions['view'] = '<a href="' . get_site_url($userblog_id) . '">Visit Site</a>'; return $actions; }
Add a custom action link with icon
Add a custom action link with an icon for site settings:
add_filter('ms_user_list_site_actions', 'add_settings_link_with_icon', 10, 2); function add_settings_link_with_icon($actions, $userblog_id) { $actions['settings'] = '<a href="' . get_admin_url($userblog_id, 'options-general.php') . '"><span class="dashicons dashicons-admin-settings"></span> Settings</a>'; return $actions; }
Reorder action links
Reorder the action links to display “View” first, followed by “Edit”:
add_filter('ms_user_list_site_actions', 'reorder_action_links', 10, 2); function reorder_action_links($actions, $userblog_id) { $new_actions = array(); if (isset($actions['view'])) { $new_actions['view'] = $actions['view']; unset($actions['view']); } if (isset($actions['edit'])) { $new_actions['edit'] = $actions['edit']; unset($actions['edit']); } return array_merge($new_actions, $actions); }