Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wp-user-manager/1529d68519bb294faa848b3a19a85730 to your computer and use it in GitHub Desktop.
Save wp-user-manager/1529d68519bb294faa848b3a19a85730 to your computer and use it in GitHub Desktop.
WP User Manager - Fix account/profile sub-page templates in WP 6.0+
<?php
add_filter( 'template_include', function ( $template ) {
global $wp;
if ( ! isset( $wp->query_vars ) ) {
return $template;
}
if ( ! isset( $wp->query_vars['page_id'] ) ) {
return $template;
}
if ( $wp->query_vars['page_id'] === wpum_get_core_page_id( 'account' ) || $wp->query_vars['page_id'] === wpum_get_core_page_id( 'profile' ) ) {
$new_template_slug = get_page_template_slug( $wp->query_vars['page_id'] );
if ( $new_template_slug && basename( $template ) !== $new_template_slug ) {
$template = dirname( $template ) . '/' . $new_template_slug;
}
}
return $template;
}, 100 );
@wp-user-manager
Copy link
Author

Save this file to your /wp-content/mu-plugins/ directory (you might need to create the mu-plugins directory).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment