Skip to content

Instantly share code, notes, and snippets.

@nikitasinelnikov
Last active December 22, 2021 12:28
Show Gist options
  • Save nikitasinelnikov/cb787277f7a62a5e3cb188bb181d9417 to your computer and use it in GitHub Desktop.
Save nikitasinelnikov/cb787277f7a62a5e3cb188bb181d9417 to your computer and use it in GitHub Desktop.
Replace Ultimate Member placeholders after nav menus rendered
remove_filter( 'wp_nav_menu_objects', 'um_add_custom_message_to_menu', 9999 );
/**
* Add dynamic profile headers
*
* @param $items
* @param $args
*
* @return mixed
*/
function um_add_custom_message_to_menu_custom( $items, $args ) {
if ( ! is_user_logged_in() ) {
$items = UM()->shortcodes()->convert_user_tags( $items );
return $items;
}
um_fetch_user( get_current_user_id() );
$items = UM()->shortcodes()->convert_user_tags( $items );
um_reset_user();
return $items;
}
add_filter( 'wp_nav_menu_items', 'um_add_custom_message_to_menu_custom', 9999, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment