Skip to:
Content
Pages
Categories
Search
Top
Bottom

profile_menu doesnt work on all pages


  • LordCoder
    Member

    @lordcoder

    Hi all ,

    i do experience a problem with my forum if i use :

    <?php if ( $bb_current_user->ID ) : ?>

    <li><h2 class="vcard">Profile</h2></li>

    <li>

    <?php profile_menu(); ?>

    </li>

    <?php endif; ?>

    instead of :

    <?php if ( is_bb_profile() ) : ?>

    <li><h2 class="vcard">Profile</h2></li>

    <li>

    <?php profile_menu(); ?>

    </li>

    <?php endif; ?>

    I wanted only that it displays the avaible profile menu for the connected user if no other profile is viewed , but it doesnt work and returns this error message :

    Warning: Invalid argument supplied for foreach() in /home/httpd/bouazza/bouazza.franceserv.com/sbouazza/forums/bb-includes/template-functions.php on line 59

    Can someone help me ?

    Thanks and merry christmas !

    Bouazza .

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

  • ardentfrost
    Member

    @ardentfrost

    Where are you changing that? I assume you’re using my Private Messages plugin (hope you like it), and if you’re changing something in functions.php or template-functions.php you could have an adverse effect on plugins.

    I also don’t exactly understand why you would test if the current user has an ID. You might want to, instead, test if the current user can do something instead of having an ID.

    Plus, I don’t think you want to use || in that setup. You probably want to use && so that if the profile exists AND something else, then it’ll display it.

    Possibly all or none of the above :)


    LordCoder
    Member

    @lordcoder

    I edited correctly the message , sorry if it was incomprehensible .

    I use that code on footer.php without modifying de template-functions.php file .

    Normally , it shows only the profil menu if a user’s profil is viewed , but i wanted that the profil menu will be displayed using the current user’s settings if no profil is viewed .


    LordCoder
    Member

    @lordcoder

    No one ?


    LordCoder
    Member

    @lordcoder

    Ok , i see that my messages are incomprehensible ( normal , i am not a native english speaker ) , i ill try again ( my english will suck a little :P ) .

    I have this on my my-templates/footer.php :

    <?php if ( $bb_current_user->ID ) : ?>

    <li><h2 class="vcard">Profile</h2></li>

    <li>

    <?php profile_menu(); ?>

    </li>

    <?php endif; ?>

    My goal is to display the avaible profil options for the connected user if no other user’s profil is viewed .

    But it doesnt work until i dont go to another user’s profil and displays this error :

    Warning: Invalid argument supplied for foreach() in /home/httpd/bouazza/bouazza.franceserv.com/sbouazza/forums/bb-includes/template-functions.php on line 59

    And only one item is viewed , Profile , and it contains a bad link ( http://bouazza.franceserv.com/sbouazza/forums/profile/, without an user ID ) .

    But if i am viewing an user’s profil , the menu is correctly displayed , and allthing is fine .

    I Hope I can get more replys now .

    Thanks !

    PS : It will be great if we can speak here on this board in another language like French , German … espiecially for guys like me who ar’nt familiar with English :P .

    Bouazza .


    LordCoder
    Member

    @lordcoder

    Ok the problem is solved by using this function instead of the default profile_menu :

    function profile_menu() {

    global $bb, $bbdb, $bb_current_user, $user_id, $profile_menu, $self, $profile_page_title, $bb_table_prefix;

    $user_id=(isset($user_id)) ? $user_id : $bb_current_user->ID;

    $list = "<ul id='profile-menu'>";

    $list .= "nt<li" . ( ( $self ) ? '' : ' class="current"' ) . '><a href="' . get_user_profile_link( $user_id ) . '">' . __('Profile') . '</a></li>';

    if ( isset( $profile_menu ) ) :

    foreach ($profile_menu as $item) {

    // 0 = name, 1 = users cap, 2 = others cap, 3 = file

    $class = '';

    if ( $item[3] == $self ) {

    $class = ' class="current"';

    $profile_page_title = $item[0];

    }

    if ( can_access_tab( $item, $bb_current_user->ID, $user_id ) )

    if ( file_exists($item[3]) || function_exists($item[3]) )

    $list .= "nt<li$class><a href='" . wp_specialchars( get_profile_tab_link($user_id, $item[0]) ) . "'>{$item[0]}</a></li>";

    }

    endif;

    $list .= "n</ul>";

    echo $list;

    }


    thomasklaiber
    Member

    @thomasklaiber

    Yeah … it’s called profile_menu because it’s for your profile and not for the whole board =)

    You can add this function (with a new name like profile_menu_global) into a plugin so you don’t have to change the core files!

    Where are you from, Germany? I’m from Germany if you need more help ;-)


    LordCoder
    Member

    @lordcoder

    K , thanks thomasklaiber , i ill create a new plugin so i don’t lose the changes on a specific update :P

    PS : i am from Morroco , but i can speak French , German , English …

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

You must be logged in to reply to this topic.