Skip to content

s2_authors

  • Subscribe2
  • Updated Nov 23, 2023
  • 1 min read

This hook allows the display list of content authors to be refined. For example, old and unused author accounts can be removed from the list without the need to delete the user account.

function remove_author($authors) {
// our function takes an array of author objects as the input
// you can then cycle through the array and remove any that you like on either 'ID' or 'display_name'
$i = 0;
foreach ( $authors as $author ) {
// example use an if statement to check if author ID should be removed compared to a known ID
if ( $author->ID == 1 ) {
unset($authors[$i]);
}
$i++;
}
return $authors;
}
add_filter('s2_authors', 'remove_author');

Last updated on

Filed under Hooks, API & Customization

Still stuck?

Our support team can walk you through it.