Display Login user name in Thim:login Popup widget

I want to display username in widget i used the code provided by its working but i want to do same for widget and its n

I want to display username in widget i used the code provided by its working but i want to do same for widget and its not working Please help with the below code.

function give_profile_name($atts){
$user=wp_get_current_user();
$name=$user->user_firstname; 
return $name;
}

add_shortcode('profile_name', 'give_profile_name');

add_filter( 'wp_nav_menu_objects', 'my_dynamic_menu_items' );
function my_dynamic_menu_items( $menu_items ) {
foreach ( $menu_items as $menu_item ) {
    if ( '#profile_name#' == $menu_item->title ) {
        global $shortcode_tags;
        if ( isset( $shortcode_tags['profile_name'] ) ) {
            // Or do_shortcode(), if you must.
            $menu_item->title = call_user_func( $shortcode_tags['profile_name'] );
        }    
    }
}

return $menu_items;
} 

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745270442a4619712.html

相关推荐

  • Display Login user name in Thim:login Popup widget

    I want to display username in widget i used the code provided by its working but i want to do same for widget and its n

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信