Hello @aswingiri and @missveronicatv
I apologize for not getting back to you sooner as I have been away on holiday. I just wanted to thank you for taking the time to try to help me and to let you know that I found a solution to my problem. I’m posting it here in case anyone else runs into the same issue:
To change the default location of custom templates intended to override default/builtin profile templates (e.g. profile/posts-single.php), you need to place the following code in a mu-file or your theme’s functions.php file:
add_filter('um_get_template', 'my_um_custom_templates_location', 10, 4);
function my_um_custom_templates_location($located, $template_name, $path, $t_args) {
if ($template_name === 'profile/posts-single.php') {
// Note that dirname(__FILE__) returns the absolute path to the directory of
// the currently running script
$located = dirname( __FILE__ ) . '/ultimate-member/templates/profile/posts-single.php';
}
return $located;
}
To specify the path to a custom template that is NOT intended to override any of the builtin/default profile templates, you need to include() the path to the template file inside a function, then add this function as a callback to the ‘um_profile_content_{$nav}‘ filter hook. For instance, I have a custom post type ‘text’ that I want to display in a custom ‘texts’ tab in users’ profiles:
add_action('um_profile_content_texts', 'my_um_profile_content_texts');
function my_um_profile_content_texts($args) {
// define text args
$text_args = array(
'author' => um_profile_id(),
'post_type' => 'text',
'post_status' => 'publish',
'numberposts' => -1, //all texts
);
// get the texts
$texts = get_posts($text_args);
if (!empty($texts)) {
foreach ($texts as $text) {
include(dirname(__FILE__) . '/ultimate-member/templates/profile/texts-single.php');
}
}
}
For instructions on how to create/add custom tabs in user profiles, see here: https://docs.ultimatemember.com/article/69-how-do-i-add-my-extra-tabs-to-user-profiles
/jenny