Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_get_loggedin_user_link'

Viewing 25 results - 1 through 25 (of 29 total)
  • Author
    Search Results
  • kanellos
    Participant

    Hi,

    I need to add an additional functionality to the submenu profile item (Activity, Groups …).
    I have found this link that is exactly what i need : buddypress-custom-pages

    But it doesnt work in my case.

    I think it’s because my submenu profile item is built (not from me) with this code in function.php:

    add_filter( 'wp_nav_menu_items', 'bpfr_custom_setup_nav', 10, 2 );

    bpfr_custom_setup_nav function returns an item containing an ul list. Each li element is built in this way:

    <li role="..." class="..."><a href="'. bp_get_loggedin_user_link() .'test-page/" class="..."><span>Test</span></a></li>
    

    But, if i create a test-page in wp, when i push the submenu Test link, I have an 404 error.

    Can someone help me?

    W.P. version: 4.9.8
    B.P. version: 3.1.0
    Theme: Avada child

    #265334
    compassioninc
    Participant

    I found what I want overridden. It is the link to “settings/”. But I want to override it from functions.php so it doesn’t get lost in updates. Thank you!

    // Add buddypress links to my dashboard widget
    add_filter('geodir_dashboard_links', 'dt_geodir_dashboard_links');
    function dt_geodir_dashboard_links($dashboard_link) {
    	if ( class_exists( 'BuddyPress' ) ) {
    		$user_link = bp_get_loggedin_user_link();
    		$dashboard_link .= '<li>';
    		$dashboard_link .= '<i class="fa fa-user"></i>';
    		$dashboard_link .= '<a href="'.$user_link.'">';
    		$dashboard_link .= __('About Me', 'gdbuddypress');
    		$dashboard_link .= '</a>';
    		$dashboard_link .= '</li>';
    
    		$dashboard_link .= '<li>';
    		$dashboard_link .= '<i class="fa fa-cog"></i>';
    		$dashboard_link .= '<a href="'.$user_link.'settings/'.'">';
    		$dashboard_link .= __('Account Settings', 'gdbuddypress');
    		$dashboard_link .= '</a>';
    		$dashboard_link .= '</li>';
    	}
    	return $dashboard_link;
    }
    jonmojo
    Participant

    Thanks Dan,

    That returns the same link as bp_loggedin_user_domain() – or http://<my site>/members/jon/ – in reality.

    I’m looking to return the raw HTML for the page or template output, not a link, when applied to:

    function bp_goto_profile_html() {

    return bp_get_loggedin_user_link();
    }

    add_shortcode(‘bp_goto_profile’, ‘bp_goto_profile_html’);

    Thanks,

    Jon.

    danbp
    Moderator

    Hi,

    try bp_get_loggedin_user_link()

    More here: http://hookr.io/plugins/buddypress/#index=g&search=loggedin_user

    #259538
    wolfpup64
    Participant

    oh wait no, thats what it was giving me in the first place…

    arrhhggh. I’ve got it down like this.

    function add_communityprofile_tab() {
    	global $bp;
    	
    	bp_core_new_nav_item( array(
    		'name'                  => 'Community',
    		'slug'                  => 'communityprofile',
    		'parent_url'            => $bp->displayed_user->domain,
    		'parent_slug'           => $bp->profile->slug,
    		'screen_function'       => 'communityprofile_screen',			
    		'position'              => 200,
    		'default_subnav_slug'   => 'communityprofile'
    	) );
    }
    function communityprofile_tab() {
       bp_core_redirect( site_url( '/community/profile/'.bp_get_loggedin_user_link()() ) );
    }
    add_action( 'bp_setup_nav', 'add_communityprofile_tab', 100 );
    #259536
    wolfpup64
    Participant

    That seems to work for pulling the appropriate user, I input it into the line shane provided

    function communityprofile_screen() {
       bp_core_redirect( site_url( '/community/profile/'.bp_get_loggedin_user_link()() ) );
    }

    but it looks like it gets overwritten by the slug in the aforementioned code that makes the tab appear and leads me to the url:

    http://localhost/wordpress/users/*username*/communityprofile/

    once again, if I try to remove the slug from the line the tab itself disappears. oh man this has been frustrating.

    #259531
    danbp
    Moderator

    Perhaps this one may work: <a href="'. bp_get_loggedin_user_link() .'">View my profile</a>

    Reference

    #259043
    danbp
    Moderator

    Hi,

    To get the link to a user profile:
    $link = bp_get_loggedin_user_link();

    Many use examples can be found on the forum. Ie:

    [Resolved] BuddyPress Links URLs

    Is it possible to make Activity and Forum profile tabs private?

    #253764

    In reply to: Custom URL

    danbp
    Moderator

    Hello @nanettedp,

    don’t be sorry, we all started a day from 0.
    You exposed (very clearly) your problem, that’s great ! The next step is to learn how to do that.

    If you ask for aid on a support forum like this one, this implies in principle you already did something (who may not work as expected for ex.) In this case, you should show us what you’ve done, so somebody can help you.

    As yo ask for a doc like a how-to, you can search on this forum or google a bit to find one. They’re plenty topics here about this, with more or less explanation and comments.

    But you say you’re a newbie. It’s not like i don’t want to help you, but i can’t teach you this. You need some tech level, even a low one and i ignore which one you already have. It’s also time consuming and as mod i have other things to do here as teaching you. Hope you understand. 😉

    As you didn’t really understand the function i indicate you, i assume you’re not familiar with php and how to use it. So you’re like i was a few years back: a newbie.

    The only thing to do is to learn. You have to experiment, to read documentation, topics and what ever related to code, WP and BP… That’s how we all acquire experience !

    Or i’m completely wrong and you meaned by i need a bit more help give me the solution. In other words, make the work for me so i can add it to my site.
    If so, you can hire a developper from here.

    Your first topic started with Is there a way that I can create a custom URL.

    Yes there is a way. It’s you! Now it’s your turn to play: create and just do it!

    #253727

    In reply to: Custom URL

    danbp
    Moderator
    #253632
    danbp
    Moderator

    Hi,

    you can use
    bp_get_loggedin_user_link
    Get the link for the logged-in user’s profile.

    or
    bp_loggedin_user_domain
    Generate the link for the logged-in user’s profile.

    Something like
    $profilelink = '<a href="'. bp_get_loggedin_user_link() .'">$user</a>';

    Famous
    Participant

    How do I create a link that takes me back from the BP profile to my original blog I signed into? I’ve tried

    
    <?php home_url( 'name' ); ?>
    <?php bp_root_domain(); ?>/<?php bp_blogs_root_slug(); ?>
    <?php echo bp_loggedin_user_domain() . bp_get_blogs_slug(); ?>
    <?php echo bp_get_loggedin_user_link(); ?>
    <?php bloginfo( $post->post_author ); ?>
    <?php site_url(); ?>
    

    Everything is a no go though :/

    Thanks

    #253437
    danbp
    Moderator

    Hi @famous,

    anything directly related to URL for bp is listed here:
    http://hookr.io/plugins/buddypress/#index=l&search=url

    In most case, you can built a link by array, which generally extend pre existing parameters. It’s very variable and depend where and how the link shoud work.

    Here some exemple snippets to add a link to a member’s profile.

    /* add external link on buddy menu bar */
    function bpfr_menubar_link() {
    global $bp;
    
    if ( !is_user_logged_in() )
        return false;
    
    $link = bp_get_loggedin_user_link();
    
    	$bp->bp_nav[$slug] = array(
    			'name'                    => 'View my profile',
    			'slug'                    => 'super_link',
    			'link'                    => $link,
    			'css_id'                  => 'super-link',	
    			'position'                => 20
    		);
    }
    add_action( 'bp_core_new_nav_item', 'bpfr_menubar_link', 999 );
    
    /* link to profile on SWA page */
    function goto_my_profile_tab() {
      if ( !is_user_logged_in() )
        return false;
    
      if ( bp_is_active( 'xprofile' ) )
    
        echo '<li><a href="'. bp_get_loggedin_user_link() .'">View my profile</a></li>';
      
    }
    add_action( 'bp_activity_type_tabs', 'goto_my_profile_tab' ); // SWA page
    add_action( 'bp_members_directory_member_types', 'goto_my_profile_tab' ); // members directory page
    
    /* shortcode linking to profile [xyz] */
    function bpfr_link_to_profile() {	
    return '<a href="'. bp_get_loggedin_user_link() .'">View my profile</a>';			
    }
    add_shortcode( 'xyz', 'bpfr_link_to_profile' );

    Another technique for groups here.

    In hope this will help you to go further.

    #243255
    danbp
    Moderator

    Use a condition.

    Function xxxxx() {
       if( is_user_logged_in() ) {
    
      echo '<li><a href="'. bp_get_loggedin_user_link() .'">View my profile</a></li>';
    
       }
    }
    #243204
    danbp
    Moderator

    This question was asked 4 days ago here:
    https://buddypress.org/support/topic/how-users-can-link-to-their-profile/

    And some other search result you can read also, here:
    https://buddypress.org/support/search/bp_get_loggedin_user_link/

    Finally, question is: which menu are you talking about ? Give details please.

    #242979
    danbp
    Moderator

    hi @nnyorker,
    use bp_get_loggedin_user_link()

    For example
    echo '<li><a href="'. bp_get_loggedin_user_link() .'">View my profile</a></li>';

    Reference

    bp_get_loggedin_user_link

    #242555

    In reply to: Add dynamic menu link

    danbp
    Moderator

    Try this:

    
    // depending the theme Main Menu, somwhere near Home, About, etc
    function bpfr_custom_setup_nav( $items) {
    	
        if ( is_user_logged_in() ) {		
            $items = '<li><a href="'. bp_get_loggedin_user_link() .'activity/news-feed/">News feed</a></li>';	
        }
        return $items;
    }
    // 10 is the priority, 1 is the position in the menu
    add_filter( 'wp_nav_menu_items', 'bpfr_custom_setup_nav', 10, 1 );
    
     

    References:

    wp_nav_menu_items


    https://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items

    #241337
    danbp
    Moderator

    Hi,

    certainly, but you have to ask for this on woocommerce support to get sure. I don’t use woocommerce…

    Something like this
    return ' <a href="'. bp_get_loggedin_user_link() .'">View my profile</a>';

    or

    echo '<a href="'.bp_core_get_user_domain($user_ID).'">'.bp_displayed_user_fullname();.'</a>';

    #237465
    andrew55
    Participant

    This is great – works perfectly – thank you.

    Are there calls, such as bp_get_loggedin_user_link, but for a link to logged in user’s friends, messages, email preferences, notifications, etc? Is there maybe a list of these calls somewhere?

    Thanks for any clarification.

    #237459
    danbp
    Moderator

    Hi @andrew55,
    add this snippet to bp-custom.php. Now you can use shortcode [profilo] in any blog post, blog comment, page and BP notice. Note that activity walls are stripped, the shortcode will not work/appear there.

    For bbPress topics and replies, use this plugin. Read the doc, as you’ll have to check user capacity to get it to work for participant.

    function bpfr_link_to_profile() {	
    
    	return ' <a href="'. bp_get_loggedin_user_link() .'">View my profile</a>';			
    }
    add_shortcode( 'profilo', 'bpfr_link_to_profile' );
    add_filter( 'comment_text', 'do_shortcode' );
    #165052
    3quid
    Participant

    Hi,

    I am trying to show the number of new mentions associated with the logged in users profile.

    I have found this page http://buddydev.com/support/forums/topic/at-mention-notification/ … I have used the last code provided by @sbrajesh

    //at mention
    
    add_action( 'bp_adminbar_menus', 'user_show_mentione_count_in_adminbar',20  );
    
    function user_show_mentione_count_in_adminbar(){
    
    global $bp;
    
    if(!is_user_logged_in()||!($count=get_user_meta( $bp->loggedin_user->id, 'bp_new_mention_count' ,true)))
    
    return;
    
    //clear it because bp won't do it on profile
    
    if(bp_is_home ()&&$bp->current_component==BP_ACTIVITY_SLUG&&$bp->current_action=="mentions")
    
    delete_user_meta($bp->loggedin_user->id, 'bp_new_mention_count');
    
    //show mentions
    
    echo  "<li ><a href='".bp_get_loggedin_user_link().BP_ACTIVITY_SLUG."/mentions/'>New mentions(".$count.")</a></li>";
    
    }

    The only thing I have changed is the last line as I don’t want a link or any HTML outputted. Just the count (even if it’s zero).

    echo  "<li ><a href='".bp_get_loggedin_user_link().BP_ACTIVITY_SLUG."/mentions/'>New mentions(".$count.")</a></li>";
    

    to

    echo  $count;
    

    It works just fine except for one thing…

    When the user has no new mentions I can’t get the code to display a ‘0’. It displays nothing at all.

    I’m pretty sure this must be a simple fix but I’ve stared at it for ages now and haven’t managed it.

    Can anyone help?

    sam_h1
    Member

    Hi guys – although I’m not new to buddypress, I am new to proper buddypress development

    Getting stuck in at the moment and I’m currently looking for the best way to include in a theme, the url for the user whose page you’re on

    I’ve found the following three potential options:
    ‘bp_user_link()
    bp_get_loggedin_user_link()
    bp_loggedinuser_link()’

    but I’m not sure if a) any of them are correct and b) how exactly to implement!

    Thanks for any help in advance

    Sam

    #105033
    modemlooper
    Moderator

    has_members()
    next_member()
    rewind_members()
    members()
    the_member()
    bp_rewind_members()
    bp_has_members( $args = ” )
    ‘type’ => $type,
    ‘page’ => $page,
    ‘per_page’ => 20,
    ‘max’ => false,
    ‘include’ => false, // Pass a user_id or comma separated list of user_ids to only show these users
    ‘user_id’ => $user_id, // Pass a user_id to only show friends of this user
    ‘search_terms’ => $search_terms, // Pass search_terms to filter users by their profile data
    ‘populate_extras’ => true // Fetch usermeta? Friend count, last active etc.

    bp_the_member()
    bp_members()
    //Misc
    bp_members_pagination_count()
    bp_members_pagination_links()
    bp_member_user_id()
    bp_get_member_user_id()
    bp_member_user_nicename()
    bp_get_member_user_nicename()
    bp_member_user_login()
    bp_get_member_user_login()
    bp_member_user_email()
    bp_get_member_user_email()
    bp_member_is_loggedin_user()
    bp_member_avatar( $args = ” )
    bp_get_member_avatar( $args = ” )
    ‘type’ => ‘thumb’,
    ‘width’ => false,
    ‘height’ => false,
    ‘class’ => ‘avatar’,
    ‘id’ => false,
    ‘alt’ => __( ‘Member avatar’, ‘buddypress’ )

    bp_member_permalink()
    bp_member_link()
    bp_get_member_link()
    bp_member_name()
    bp_get_member_name()
    bp_member_last_active()
    bp_get_member_last_active()
    bp_member_latest_update( $args = ” )
    bp_get_member_latest_update( $args = ” ) {
    ‘length’ => 15

    bp_member_profile_data( $args = ” )
    ‘field’ => false, // Field name
    bp_member_registered()
    bp_get_member_registered()
    bp_member_add_friend_button()
    bp_add_friend_button( $members_template->member->id, $friend_status )
    bp_member_total_friend_count()
    bp_get_member_total_friend_count()
    bp_member_random_profile_data()
    bp_member_hidden_fields()
    bp_directory_members_search_form()
    bp_total_site_member_count()
    bp_get_total_site_member_count()
    //Check bp-core-templatetags.php for comments about nav tags
    bp_get_loggedin_user_nav()
    bp_get_displayed_user_nav()
    bp_get_options_nav()
    bp_get_options_title()
    //Avatar Tags
    bp_has_options_avatar()
    bp_get_options_avatar()
    bp_comment_author_avatar()
    bp_post_author_avatar()
    bp_loggedin_user_avatar( $args = ” )
    bp_get_loggedin_user_avatar( $args = ” ) {
    ‘type’=> ‘thumb’,
    ‘width’=> false,
    ‘height’=> false,
    ‘html’=> true

    bp_displayed_user_avatar( $args = ” )
    bp_get_displayed_user_avatar( $args = ” )
    ‘type’=> ‘thumb’,
    ‘width’=> false,
    ‘height’=> false,
    ‘html’=> true

    bp_avatar_admin_step()
    bp_get_avatar_admin_step()
    bp_avatar_to_crop()
    bp_get_avatar_to_crop()
    bp_avatar_to_crop_src()
    bp_get_avatar_to_crop_src()
    bp_avatar_cropper()
    //Other
    bp_site_name()
    bp_core_get_wp_profile()
    bp_get_profile_header()
    bp_exists( $component_name )
    bp_format_time( $time, $just_date = false )
    bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true )
    bp_your_or_their( $capitalize = true, $echo = true )
    bp_get_plugin_sidebar()
    bp_page_title()
    bp_get_page_title()
    bp_styles()
    bp_has_custom_signup_page()
    bp_signup_page()
    bp_get_signup_page()
    bp_has_custom_activation_page()
    bp_activation_page()
    bp_get_activation_page()
    bp_search_form_enabled()
    bp_search_form_action()
    bp_search_form_type_select()
    bp_search_form()
    bp_log_out_link()
    bp_custom_profile_boxes()
    bp_custom_profile_sidebar_boxes()
    bp_create_excerpt( $text, $excerpt_length = 55, $filter_shortcodes = true )
    bp_is_serialized( $data )
    bp_total_member_count()
    bp_get_total_member_count()
    bp_signup_username_value()
    bp_get_signup_username_value()
    bp_signup_email_value()
    bp_get_signup_email_value()
    bp_signup_with_blog_value()
    bp_get_signup_with_blog_value()
    bp_signup_blog_url_value()
    bp_get_signup_blog_url_value()
    bp_signup_blog_title_value()
    bp_get_signup_blog_title_value()
    bp_signup_blog_privacy_value()
    bp_get_signup_blog_privacy_value()
    bp_signup_avatar_dir_value()
    bp_get_signup_avatar_dir_value()
    bp_current_signup_step()
    bp_get_current_signup_step()
    bp_signup_avatar( $args = ” )
    bp_get_signup_avatar( $args = ” ) {
    ‘size’ => BP_AVATAR_FULL_WIDTH,
    ‘class’ => ‘avatar’,
    ‘alt’ => __( ‘Your Avatar’, ‘buddypress’ )
    bp_signup_allowed()
    bp_get_signup_allowed()
    bp_blog_signup_allowed()
    bp_get_blog_signup_allowed()
    bp_account_was_activated()
    bp_registration_needs_activation()
    bp_mentioned_user_display_name( $user_id_or_username )
    bp_get_mentioned_user_display_name( $user_id_or_username )
    bp_get_option( $option_name )
    bp_ajax_querystring( $object = false )
    bp_last_activity( $user_id = false, $echo = true )
    bp_user_has_access()
    bp_user_firstname()
    bp_get_user_firstname()
    bp_loggedin_user_link()
    bp_get_loggedin_user_link()
    bp_loggedinuser_link()
    bp_displayed_user_link()
    bp_get_displayed_user_link()
    bp_user_link()
    bp_displayed_user_id()
    bp_current_user_id()
    bp_loggedin_user_id()
    bp_displayed_user_domain()
    bp_loggedin_user_domain()
    bp_displayed_user_fullname()
    bp_get_displayed_user_fullname()
    bp_user_fullname() { echo bp_get_displayed_user_fullname()
    bp_loggedin_user_fullname()
    bp_get_loggedin_user_fullname()
    bp_displayed_user_username()
    bp_get_displayed_user_username()
    bp_loggedin_user_username()
    bp_get_loggedin_user_username()
    bp_current_component()
    bp_current_action()
    bp_current_item()
    bp_action_variables()
    bp_root_domain()
    bp_get_root_domain()
    //Conditionals
    bp_is_blog_page()
    bp_is_my_profile()
    bp_is_home()
    bp_is_front_page()
    bp_is_activity_front_page()
    bp_is_directory()
    bp_is_page($page)
    bp_is_active( $component )
    bp_is_profile_component()
    bp_is_activity_component()
    bp_is_blogs_component()
    bp_is_messages_component()
    bp_is_friends_component()
    bp_is_groups_component()
    bp_is_settings_component()
    bp_is_member()
    bp_is_user_activity()
    bp_is_user_friends_activity()
    bp_is_activity_permalink()
    bp_is_user_profile()
    bp_is_profile_edit()
    bp_is_change_avatar()
    bp_is_user_groups()
    bp_is_group()
    bp_is_group_home()
    bp_is_group_create()
    bp_is_group_admin_page()
    bp_is_group_forum()
    bp_is_group_activity()
    bp_is_group_forum_topic()
    bp_is_group_forum_topic_edit()
    bp_is_group_members()
    bp_is_group_invites()
    bp_is_group_membership_request()
    bp_is_group_leave()
    bp_is_group_single()
    bp_is_user_blogs()
    bp_is_user_recent_posts()
    bp_is_user_recent_commments()
    bp_is_create_blog()
    bp_is_user_friends()
    bp_is_friend_requests()
    bp_is_user_messages()
    bp_is_messages_inbox()
    bp_is_messages_sentbox()
    bp_is_notices()
    bp_is_messages_compose_screen()
    bp_is_single_item()
    bp_is_activation_page()
    bp_is_register_page()
    bp_the_body_class()
    bp_get_the_body_class( $wp_classes, $custom_classes = false )

    #79636
    rich! @ etiviti
    Participant

    filed a ticket
    https://trac.buddypress.org/ticket/2409

    fat finger? – returning the logged in user instead of the displayed user

    function bp_displayed_user_link() {
    echo bp_get_loggedin_user_link();
    }
    function bp_user_link() { bp_displayed_user_link(); }

    where both should be point to:

    function bp_get_displayed_user_link() {
    global $bp;

    return apply_filters( ‘bp_get_displayed_user_link’, $bp->displayed_user->domain );
    }

    r-a-y
    Keymaster

    Here’s what I’m using for:

    My Profile tab:

    <?php if(is_user_logged_in()) : ?>
    <li<?php if ( bp_is_my_profile() ): ?> class="selected"<?php endif; ?>>
    <a href="<?php echo bp_get_loggedin_user_link(); ?>" title="<?php _e( 'My Profile', 'buddypress' ) ?>"><?php _e( 'My Profile', 'buddypress' ) ?></a>
    </li>
    <?php endif; ?>

    Members tab:

    <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() && !bp_is_my_profile()) : ?> class="selected"<?php endif; ?>>
    <a href="<?php echo site_url() ?>/<?php echo BP_MEMBERS_SLUG ?>/" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a>
    </li>

    Slightly simpler than yours. But if there’s an even, simpler way let me know!

Viewing 25 results - 1 through 25 (of 29 total)
Skip to toolbar