Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Logged-In User Profile Link URL

  • @paintermommy

    Participant

    I have searched and searched for at least 2 hours now and I am not finding a solution.

    I am setting up a community through Buddypress on a client site. Here is what it looks like so far: http://www.soulwomansanctuary.com/community/

    I have set up the sidebar and WordPress menu to have links to things like Community Members. Activity, Forum, etc. I have also added a link called “Edit Profile” which I would like to link to the user’s profile page. I have it set up this way because I am not going to be using the normal Buddypress sidebar widget. I am going through Wishlist member so that only members can access the community.

    I have tried all different things to get the link and nothing seems to be working.

    Here are some of the links that people have suggested using:
    http://soulwomansanctuary.com/community-members/USERNAME/profile/
    http://soulwomansanctuary.com/community-members/%username%/profile

    I appreciate any help that you might have.

Viewing 12 replies - 26 through 37 (of 37 total)
  • @bphelp

    Participant

    @bphelp

    Participant

    Let me know if it worked for you as well!

    @struth

    Participant

    I just hijacked Mr Jacoby code:

    add_action('after_setup_theme', 'remove_admin_bar');     // remove admin bar for users
    
    function remove_admin_bar() {
    if (!current_user_can('administrator') && !is_admin()) {
      show_admin_bar(false);
    }
    }
    
     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()){     //show buddypress user profile page
    		global $current_user;
    		wp_redirect( get_bloginfo('url') . '/members/'. $current_user->user_login . '/profile/'); 
    		exit();
    	}
     }
    add_action('init', 'redirect2profile');
    
    ?>

    Into a plugin for those who don’t know how, or just don’t want to add this code to the functions.php file. you can download it HERE

    Removes the admin bar for all users except Administrators and gets “global $current_user;” profile to a page you create called Profile as described by jackreichert

    I’ve said it before but I’m going to say it again – you’re a genius Mr Jacoby

    @xiot

    Participant

    @bphelp

    This looks nice but wasn’t what I was looking for since I have a frontpage already and don’t want to change it!
    But the link within the code was pretty helpfull! I couldn’t find out where to find the bp-custom.php. Now I know that it has to be created 😀 Thanks anyway!

    And also thanks to @struth !
    Cause of you i found out how to switch the result of is_user_logged_in() . It’s a simple “!” that needs to be in front of the function!

    But I still can’t imagine why the snippet was named to direct visitors to the registration page! It doesn’t do that.

    Now the code is modded and it DOES redirect not logged in users to the registration page!

    Feel free to use it 🙂

     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') . '/member/'. $current_user->user_login . '/profile/'); 
    		exit();
    	} else {
    		if ($_SERVER['REQUEST_URI'] == '/profile/' && is_plugin_active('buddypress/bp-loader.php') && !is_user_logged_in()) {
    		wp_redirect( get_bloginfo('url') . '/register/'); 
    		exit();
    		}}
    			
     }
    add_action('init', 'redirect2profile');
    

    Cheers, Lars

    @struth

    Participant

    I was quietly hoping you would figure this out, well done Lars.

    Will test it out in adminbarbegone tomorrow, looks good, Thanks for being open with you code and posting, this will help me alot. I couldn’t get this code to redirect not logged in users to the registration page but then, I’m a n00b with php; lol

    s2Members uses ! a lot in short code
    [s2If !is_user_logged_in()]if user is not logged in show this [/s2If]


    @paintermommy
    might find s2Members quite useful at soulwomansanctuary but it looks like she has sorted it out

    Next I need to work on an admin page to switch functions on and off, should be fun but I keep getting side tracked with responsibilities.

    @bphelp

    Participant

    @xiot
    You said:

    I want the code to redirect the not logged in user to a register page

    Next time you request help please make sure you are more specific. One minute you say you want the logged out users to be redirected to the register page, then you flip and say you have a front page and don’t want to change it. When we offer code here a lot of times it is dependent on what you specifically ask for.

    @xiot

    Participant

    @bphelp

    Yeah sorry, I thought it would be clear because i referred to a certain code. The whole block I wrote above the quote you posted was about the code I also posted.

    Sooo.. let’s just handle it as a communication problem! Then again, thanks for the idea and the help and sorry that I wasn’t specific enough. I am not a native of the english language.

    Regards, Lars

    @bphelp

    Participant

    @xiot
    There is no problem, I simply meant that by being more specific it will help all of the volunteers help you more efficiently next time around! 🙂

    @xiot

    Participant

    @bphelp

    🙂 yeah sorry, I’ll keep that in mind. I will be more specific next time so the helping hands can actually help 😉

    Thanks bphelp 🙂

    @bridieamelia

    Participant

    Hi, this thread was really helpful to me trying to add a link on my homepage to the logged in user’s profile page.

    I ended up writing it up as a shortcode so thought I’d post here for future seekers.

    function myprofile_shortcode() {
    	global $current_user;
    	get_currentuserinfo(); 
    	$myprofileurl = '<a href="'. home_url() . '/members/' . $current_user->user_login . '/profile/">My Profile</a>';
    	return $myprofileurl;
    }
    add_shortcode('myprofileurl', 'myprofile_shortcode');

    Happy days 🙂

    @zwrodgers

    Participant

    @bridieamelia

    I’m not a developer and don’t know a ton about coding. Where do I paste this for it to work?

    And then how do I use it?

    @danbp

    Participant

    Shortcodes are used by WordPress since version 2.5.

    https://codex.wordpress.org/Shortcode
    https://codex.wordpress.org/Shortcode_API

    To use the above snippet, you copy/paste it into your child-theme functions.php.
    And you use the shortcode like this [myprofileurl] within post or comments.

    Bla bla bla [myprofileurl] bla bla… will print out Bla bla bla My Profile bla bla…

    I hope for you that you want to write something else before My profile as bla bla bla 😉

Viewing 12 replies - 26 through 37 (of 37 total)
  • The topic ‘[Resolved] Logged-In User Profile Link URL’ is closed to new replies.
Skip to toolbar