Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Logged-In User Profile Link URL

Viewing 25 replies - 1 through 25 (of 37 total)

  • Roger Coathup
    Participant

    @rogercoathup

    It’s a dynamic URL — i.e. it changes for each user, so you can’t just type in a single link in html.

    It’s easy to do with a bit of PHP code though — just call the function bp_loggedin_user_domain()

    Something like this should work:
    `if ( is_user_logged_in() ) {
    global $current_user;
    $username = $current_user->user_login;
    echo ‘ | My Profile‘;
    }`


    paintermommy
    Participant

    @paintermommy

    Thankyou so much for your fast reply! Can I just insert this code into a text widget? Or do I need a special plugin?


    paintermommy
    Participant

    @paintermommy

    That did not work for me Toby. :( I even added a special PHP widget. Any ideas?


    Roger Coathup
    Participant

    @rogercoathup

    Use the function I provided – there’s no need to try and construct the URL yourself (as Toby has tried).


    paintermommy
    Participant

    @paintermommy

    I am not great with code so my apologies, but how would I do that exactly? I am trying to add a link in the sidebar along with the other community links. Do I need the PHP widget and then add specific code with your “function”? Can you provide the exact code? Sorry again to be a pain. My client is about to give up on it altogether so I just want to try one last time to see if we can get it working.

    Thanks so much for your help. I appreciate it.

    @rogercoathup is right. Use `bp_loggedin_user_domain()` and not my function. :) …note to self, update header code in my theme…

    Regarding how and where to add the code, try adding the following to your template:

    What is the result?


    paintermommy
    Participant

    @paintermommy

    Hi Toby. I am not seeing any code. Maybe you can email it to me? Dawn(at)DPK-GraphicDesign.com. I soooo appreciate your help.


    paintermommy
    Participant

    @paintermommy

    And just a reminder… I need the code to add to the widget to get the link to work under the other links in the sidebar. Thankyou!


    paintermommy
    Participant

    @paintermommy

    I am still looking for help. Anyone?


    k8peterson
    Participant

    @k8peterson

    I am looking for the code to this function as well! I would like to add it as a main menu item. would appreciate any help!


    @mercime
    Participant

    @mercime

    https://wordpress.org/extend/plugins/buddypress-profile-menu/screenshots/

    @paintermommy k8peterson Create custom menu and use the menu widget for sidebar.


    k8peterson
    Participant

    @k8peterson

    thank you @mercime !


    paintermommy
    Participant

    @paintermommy

    I had no idea that this plugin existed. Thankyou!


    ihiustler
    Participant

    @ihiustler

    @paintermommy did you ever get this to work with the wishlist plugin? Are your forums private and only for paid members?


    bookee
    Participant

    @bookee

    @mercime, your solution works for my site. However, I’dd like to add the menu as a child menu. Looking at the source code, I know this much information about the parent menu (id=”menu-item-822″). How would I proceed? Please assist.

     

    Thanks.


    @mercime
    Participant

    @mercime

    @bookee is this related to the login link you wanted in other post?


    bookee
    Participant

    @bookee

    @mercime, thanks for the reply. Yes, this is somewhat related with my request on the other post. In this case, the menu position being the different factor. I appreciate the support, I truly do.


    @mercime
    Participant

    @mercime


    alvinzach
    Participant

    @alvinzach

    @paintermommy
    try this a href="<?php bp_loggedinuser_link() ?>"> profile


    Jack Reichert
    Participant

    @jackreichert

    To solve this I decided to hijack a page. If the member is logged in, they get their profile, otherwise, they go to a signup page.

    Just pop the following code into your functions.php file… and create a page named ‘profile’. Now you can add that page to your WP menu and it should do what you need.

     function redirect2profile(){
    	include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    	if($_SERVER['REQUEST_URI'] == '/profile/' && is_plugin_active('buddypress/bp-loader.php') && is_user_logged_in()){
    		global $current_user;
    		wp_redirect( get_bloginfo('url') . '/members/'. $current_user->user_login . '/profile/'); 
    		exit();
    	}
     }
    add_action('init', 'redirect2profile');

    gediweb
    Participant

    @gediweb

    @jackreichert Worked perfectly for me. thank you!


    craig
    Participant

    @craigheyworth

    A few years ago I set up my first buddypress site and sold it.

    I definitely remember using a dynamic url for links to the users profile, activity stream etc.

    It was something like:

    http://www.mydomain.com/member/$profile/

    Are we all sure that this can no longer be done?


    struth
    Participant

    @struth

    @jackreichert your a bloody genius Mr Jacoby, buddyPress just gets better & then some, thanks you mate!

    Do you mind if I include your code in my “n00bish” wp plugin:

    function redirect2profile(){
    include_once( ABSPATH . ‘wp-admin/includes/plugin.php’ );
    if($_SERVER[‘REQUEST_URI’] == ‘/profile/’ && is_plugin_active(‘buddypress/bp-loader.php’) && is_user_logged_in()){
    global $current_user;
    wp_redirect( get_bloginfo(‘url’) . ‘/members/’. $current_user->user_login . ‘/profile/’);
    exit();
    }
    }
    add_action(‘init’, ‘redirect2profile’);

    I’m just beginning my journey into php & I’ve always wanted to write a toolbox for wp and buddy, you gotta start somewhere : )

    PS:Do I credit you in the plugin as a contributor?

    Best Regards
    John Hart


    xiot
    Participant

    @xiot

    Hi there!

    This worked quite fine for me, but i have the problem that this code doesnt bring me to a signup page when you aren’t logged in.

    I tried to add the redirect with “else” but it didn’t work for me either.
    The code has now changed, since I tried to figure out why it doesn’t redirect me to my register page.

    I’m not very skilled with PHP so maybe someone can help me out.
    I want the code to redirect the not logged in user to a register page

      function redirect2profile(){
    	include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    		if ( is_user_logged_in()){
    		if ($_SERVER['REQUEST_URI'] == '/profile/' && is_plugin_active('buddypress/bp-loader.php')) {
    			global $current_user;
    			wp_redirect( get_bloginfo('url') . '/member/'. $current_user->user_login . '/profile/'); 
    			exit();
    			}
    	} else {
    		if ($_SERVER['REQUEST_URI'] == '/profile/' && is_plugin_active('buddypress/bp-loader.php')) {
    		wp_redirect( get_bloginfo('url') . '/register/');
    		exit();
    		}
    		}
    		 }
    add_action('init', 'redirect2profile');
    
Viewing 25 replies - 1 through 25 (of 37 total)
  • The topic ‘[Resolved] Logged-In User Profile Link URL’ is closed to new replies.
Skip to toolbar