Skip to:
Content
Pages
Categories
Search
Top
Bottom

link admin bar change


  • cocolabombe0
    Participant

    @cocolabombe0

    Hello, I tried to change the links in the admin bar to display the profile and the change in bbpress mode.
    I saw that there was the option (Edit Profile link). I did not see at first.
    But I have a problem. When I click on the name (nickname or surname first name as I Poster) I want ca redirected to root / member / user instead of root / member / user / edit.
    To change the profile, I agree that this is only one must have the root link / member / user / edit.
    How to do?
    Sincerely Nicolas.

Viewing 20 replies - 1 through 20 (of 20 total)

  • Robkk
    Moderator

    @robkk

    If you used code from the codex for an profile link in your menu, if you want it to lead to the edit section of your profile just add /edit to the url in the code.


    cocolabombe0
    Participant

    @cocolabombe0

    no, I have not used the codex.
    I checked the box of bbpress option.
    And the links are replaced.
    http://www.hostingpics.net/viewer.php?id=857251bbpress.jpg


    Robkk
    Moderator

    @robkk

    I think you using bbp-avatar plugin??

    That checkbox for the edit profile link only modifies the edit profile link in the WordPress toolbar and nothing else.

    https://github.com/imath/bbp-avatar/


    cocolabombe0
    Participant

    @cocolabombe0

    Oh yes, this is what plugin that added this option.
    But I think I have to change the file after a shot on the admin bar file to separate the two codes.
    But I do not know too so it’ll be tough.


    cocolabombe0
    Participant

    @cocolabombe0

    Found
    file /wp-includes/admin-bar.php

    if ( $current_user->display_name !== $current_user->user_login )
    $user_info .= “<span class=’username’>{$current_user->user_login}</span>”;

    $wp_admin_bar->add_menu( array(
    ‘parent’ => ‘user-actions’,
    ‘id’ => ‘user-info’,
    ‘title’ => $user_info,
    ‘href’ => (‘/forums/membre/’. $current_user->user_login),
    ‘meta’ => array(
    ‘tabindex’ => -1,
    ),
    ) );

    The link works.


    Robkk
    Moderator

    @robkk

    Yeah I do not know really either, because of that I am going to say this is custom development and you need to hire someone to do it for you or figure it out yourself.


    cocolabombe0
    Participant

    @cocolabombe0

    I just edit my previous message because I finally solved my problem.

    With each update, the file is overwritten or not?


    Robkk
    Moderator

    @robkk

    If you edited that file, then you edited a WordPress core file (which you should not do) and when WordPress updates again the file will be overwritten.


    cocolabombe0
    Participant

    @cocolabombe0

    OK. I have to because it is the wordpress code that displays the name of the pseudo code and modify the profile.

    @cocolabombe0 I see you already have a ticket here 🙂

    Did the link to the code I sent you help?


    cocolabombe0
    Participant

    @cocolabombe0

    the link?
    I do not see how we can do to have a variable and divide it into two.
    If not, i thought the easiest way to do not touch the core of WordPress is created a condition more about $profile_url will either go to /forums/membre/user or go to /forums/membre/user/edit

    bbPress has quite a few functions that will help you here:

    bbp_get_user_profile_url() would get you /forums/membre/user
    bbp_get_user_profile_edit_url() would get you /forums/membre/user/edit

    You can also use bbp_get_current_user_id() if you need the current user ID


    cocolabombe0
    Participant

    @cocolabombe0

    It is these values but I tried to create a function to replace values but I do not know it at all.
    I try to put code in my function.php not affect my wordpress (update)


    cocolabombe0
    Participant

    @cocolabombe0

    Problèm ok

    function edit_url_profil_bar_admin( $wp_admin_bar ) {
    	
    	global $current_user;
    $wp_admin_bar->add_node( array(
    	'id' => 'my-account',
    	'href'      => ('/forums/membre/'. $current_user->user_login),
        ) );
    
    $wp_admin_bar->add_node( array(
    	'id' => 'user-info',
    	'href' => ('/forums/membre/'. $current_user->user_login),
        ) );
    	
    	$wp_admin_bar->add_node( array(
    	'id' => 'edit-profile',
    	'href' => ('/forums/membre/'. $current_user->user_login .'/edit/'),
        ) );
    }
    	add_filter( 'admin_bar_menu', 'edit_url_profil_bar_admin' ); 

    with this code, I have exactly what I wanted.
    I helped myself this http://www.geekpress.fr/wordpress/tutoriel/modifier-howdy-admin-bar-1102/ code to make the change. In addition, I took a piece of their code as I removed the greeting. I just put the code to change the links.


    cocolabombe0
    Participant

    @cocolabombe0

    now I have other worries.
    I want to change the display of links for users and not for admins.
    But I did not find what id done that?
    On the site title (just left of the toolbar), what is the code that I redo a function?


    cocolabombe0
    Participant

    @cocolabombe0

    I found better. How to tell the function that the visitor and the user can not see the site-name.

    /**
     * Add the "Site Name" menu.
     *
     * @since 3.3.0
     *
     * @param WP_Admin_Bar $wp_admin_bar
     */
    function wp_admin_bar_site_menu( $wp_admin_bar ) {
    	// Don't show for logged out users.
    	if ( ! is_user_logged_in() )
    		return;
    
    	// Show only when the user is a member of this site, or they're a super admin.
    	if ( ! is_user_member_of_blog() && ! is_super_admin() )
    		return;

    In the code, “simply remove the code ! is_user_member_of_blog() &&” but how to write a function.

    f ( ! is_super_admin() )
    		return;

    cocolabombe0
    Participant

    @cocolabombe0

    function my_admin_bar_render() {
        if (! is_super_admin() )
    	{
    	global $wp_admin_bar;
        $wp_admin_bar->remove_menu('site-name');
    }
    }
    add_action( 'wp_before_admin_bar_render', 'my_admin_bar_render' );

    This code is ok.


    Robkk
    Moderator

    @robkk

    Glad you solved your own issue. 🙂


    cocolabombe0
    Participant

    @cocolabombe0

    Yes, I have exactly the behavior I want (almost) but the result is conclusive for me.
    Much research, testing to get lost between what I disable, enable, modify the original files, etc.


    josmanban
    Participant

    @josmanban

    thanks

Viewing 20 replies - 1 through 20 (of 20 total)
  • You must be logged in to reply to this topic.
Skip to toolbar