UCDavisLibrary / ucdlib-theme-wp

Wordpress theme port of the UC Davis SiteFarm One Theme
2 stars 0 forks source link

Option to not show public users page #263

Closed spelkey-ucd closed 7 months ago

spelkey-ucd commented 7 months ago

On certain sites, we might want to hide the user/author page.

Need two settings:

  1. Hide from sitemap Which will have the following code:
add_filter( 'wp_sitemaps_add_provider', function ( $provider, $name ) {
    if ( 'users' === $name ) {
        return false;
    }

    return $provider;
}, 10, 2 );

add_filter( 'wp_sitemaps_register_providers', function ( $providers ) {
    unset( $providers['users'] );
    return $providers;
} );
  1. Redirect to 404

in author.php

  global $wp_query;
  $wp_query->set_404();
  status_header( 404 );
  get_template_part( 404 ); exit();
spelkey-ucd commented 7 months ago

released v3.7.0