The ms_user_row_actions WordPress PHP action allows you to modify the action links displayed under each user in the Network Admin Users list table.
Usage
add_filter('ms_user_row_actions', 'your_custom_function', 10, 2); function your_custom_function($actions, $user) { // your custom code here return $actions; }
Parameters
- $actions (string[]): An array of action links to be displayed. Default ‘Edit’, ‘Delete’.
- $user (WP_User): WP_User object representing the user.
More information
See WordPress Developer Resources: ms_user_row_actions
Examples
Add a custom link to view user’s posts
This example adds a “View Posts” link to view the user’s posts in a new tab.
add_filter('ms_user_row_actions', 'add_view_posts_link', 10, 2); function add_view_posts_link($actions, $user) { $actions['view_posts'] = '<a href="' . admin_url('edit.php?author=' . $user->ID) . '" target="_blank">View Posts</a>'; return $actions; }
Remove ‘Delete’ action link
This example removes the ‘Delete’ action link for all users.
add_filter('ms_user_row_actions', 'remove_delete_action', 10, 2); function remove_delete_action($actions, $user) { unset($actions['delete']); return $actions; }
Add a custom link to reset user password
This example adds a “Reset Password” link that sends a password reset email to the user.
add_filter('ms_user_row_actions', 'add_reset_password_link', 10, 2); function add_reset_password_link($actions, $user) { $actions['reset_password'] = '<a href="' . wp_lostpassword_url() . '&user_login=' . urlencode($user->user_login) . '">Reset Password</a>'; return $actions; }
Change ‘Edit’ action link text
This example changes the ‘Edit’ action link text to ‘Modify’.
add_filter('ms_user_row_actions', 'change_edit_action_text', 10, 2); function change_edit_action_text($actions, $user) { $actions['edit'] = str_replace('Edit', 'Modify', $actions['edit']); return $actions; }
Conditionally remove ‘Delete’ action link
This example removes the ‘Delete’ action link only for users with a specific email domain.
add_filter('ms_user_row_actions', 'conditionally_remove_delete_action', 10, 2); function conditionally_remove_delete_action($actions, $user) { if (strpos($user->user_email, '@example.com') !== false) { unset($actions['delete']); } return $actions; }