WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Admin Bar Modification (4 posts)

  1. almb1111
    Member
    Posted 2 years ago #

    I want to edit the my-account in admin-bar.php, because I hided the back-end from the users, but the href in my-account is :
    'href' => $profile_url,

    I want to make it link to http://site.com/author/USERNAME , where USERNAME is the username of the logged in user.
    So , what would the href become ?

  2. almb1111
    Member
    Posted 2 years ago #

    come on I dont think my question is that complicated, cant anyone help me ?

  3. jsing
    Member
    Posted 2 years ago #

    Keep in mind I have no idea what I am doing... this returns the url that you want:

    $current_user = wp_get_current_user();
    $current_name = $current_user->user_login;
    $url = site_url('/author/');
    
    echo $url . $current_name;

    So after adding all but the last line of that to define the two partsabove the 'href' I think you could then say:

    'href' => $url . $current_name;

    or one more step (probably unnecessary)

    $current_user = wp_get_current_user();
    $current_name = $current_user->user_login;
    $url = site_url('/author/');
    $new_url = $url . $current_name;
    
    'href' =>$new_url;

    I am sure someone else probably knows a better way but at least this should get you going in the right direction.

  4. almb1111
    Member
    Posted 2 years ago #

    thanks alot man, it works.
    THANK YOU

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags