Skip to:
Content
Pages
Categories
Search
Top
Bottom

A couple of beginner questions.


  • edinchez
    Participant

    @edinchez

    Hi guys. How can I make it so it displays the users by nicknames, not by their names?
    And, how can I add Activity and Members links in the adminbar?

    Thanks in advance!

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

  • edinchez
    Participant

    @edinchez

    anyone? please!


    Virtuali
    Participant

    @gunju2221

    <i> How can I make it so it displays the users by nicknames, not by their names?</i>

    That is what Buddypress does currently. It displays their “RealName” rather than their Username across the site.

    <i> how can I add Activity and Members links in the adminbar?</i>

    Add this to your bp-custom.php:

    function pages(){
    ?>
    
    <li class="no-arrow"><a href="yoursite.com/activity">Activity</a>
    
    <li class="no-arrow"><a href="yoursite.com/groups/">Groups</a>
    
    <?php
    }
    add_action( 'bp_adminbar_menus', 'pages', 15 );

    edinchez
    Participant

    @edinchez

    “That is what Buddypress does currently. It displays their “RealName” rather than their Username across the site.”

    But I want it to display their usernames instead of their RealNames. And the code is giving me an error:

    Parse error: syntax error, unexpected ‘}’ in xxx/public_html/wp-content/plugins/bp-custom.php on line 9

    Note that I just created the bp-custom.php file. Oh, and, how can I add a search bar in the adminbar? but not the BP searchbar, i want to add the wordpress default searchbar. Thanks!


    Virtuali
    Participant

    @gunju2221

    And the code is giving me an error:

    Parse error: syntax error, unexpected ‘}’ in xxx/public_html/wp-content/plugins/bp-custom.php on line 9

    Make sure it has been wrapped around “ at the beginning and the end.

    But I want it to display their usernames instead of their RealNames.

    Use this plugin: https://wordpress.org/extend/plugins/buddypress-usernames-only/


    edinchez
    Participant

    @edinchez

    thanks a loooot! anything on how to add the searchbar in the adminbar?


    Virtuali
    Participant

    @gunju2221

    Try something like this in your bp-custom:

    function new_search_action() {
    global $bp;
    
    return apply_filters( 'new_search_action', $bp->root_domain . '/search' );
    }
    
    function custom_adminbar_search() {
    $mobSearch = '
    <li class="align-right"><form action="' . new_search_action() . '" method="post" id="search-form">
    
    ' . bp_search_form_type_select() . '
    
    ' . wp_nonce_field( 'bp_search_form' ) . '
    </form></li>
    ';
    
    echo apply_filters( 'bp_search_form', $mobSearch );
    }
    add_action('bp_adminbar_menus', 'custom_adminbar_search', 100);

    Tell me how that works.


    edinchez
    Participant

    @edinchez

    it works but i said i wanted the default wp search, not the bp search (like searching for members), because i want it to be able to search the whole site, not just members. by the way, the “submit” button is blank, and it’s a bit bigger than the adminbar.

    Btw, how can i make it so those links i added on the adminbar, only show to logged in people? because the current ones are showing to logged out people too..


    edinchez
    Participant

    @edinchez

    anyone?


    Boone Gorges
    Keymaster

    @boonebgorges

    To hide something from non-logged-in users, surround it in is_user_logged_in() checks, like so

    if ( is_user_logged_in() ) {
    \ stuff that only logged in users should see
    }

    edinchez
    Participant

    @edinchez

    It’s not working :(

    I’m using this code for the links in the adminbar:

    function pages(){
    ?>
    
    <li class="no-arrow"><a href="http://www.authentic-pictures.com/activity/">Activity</a>
    
    <li class="no-arrow"><a href="http://www.authentic-pictures.com/members/">Members</a>
    
    <?php
    }
    add_action( 'bp_adminbar_menus', 'pages', 15 );
    
    ?>

    And when I tried to add those like this:

    if ( is_user_logged_in() ) {
    function pages(){
    ?>
    
    <li class="no-arrow"><a href="http://www.authentic-pictures.com/activity/">Activity</a>
    
    <li class="no-arrow"><a href="http://www.authentic-pictures.com/members/">Members</a>
    
    <?php
    }
    add_action( 'bp_adminbar_menus', 'pages', 15 );
    }
    
    ?>

    It didn’t work..

    I also tried like this:

    function pages(){
    ?>
    
    if ( is_user_logged_in() ) {
    <li class="no-arrow"><a href="yoursite.com/activity">Activity</a>
    
    <li class="no-arrow"><a href="yoursite.com/groups/">Groups</a>
    }
    
    <?php
    }
    add_action( 'bp_adminbar_menus', 'pages', 15 );

    Still didn’t work.. any ideas? :(


    Virtuali
    Participant

    @gunju2221

    Does it not appear?

    You need to insert it in your bp-custom.php


    edinchez
    Participant

    @edinchez

    Virtuali, if you’re asking about the search, I don’t need it anymore. But, can you please help me with making the activity and members links in the adminbar only show to logged in users?


    Virtuali
    Participant

    @gunju2221

    Should be

    function pages(){
    ?>
    
    <li class="no-arrow"><a href="yoursite.com/activity">Activity</a>
    
    <li class="no-arrow"><a href="yoursite.com/groups/">Groups</a>
    
    <?php
    }
    add_action( 'bp_adminbar_menus', 'pages', 15 );
Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘A couple of beginner questions.’ is closed to new replies.
Skip to toolbar