How do I create a generic link including the username in it?

Hi! In the NETWORK Theme when you get requested to be a friend you get an email and when you click you have to log in, and then it takes you to the home instead of the Requests page: http://example.com/members/username/requests. So I will solve this by putting a link on the home page that says Friendship Requests with the current usernames ID in the link. The problem is that I don´t know how to do that link I don´t know how to tell the system to take the "current" user to his page I´m missing a way of inserting http://example.com/members/currentusername/requests in the link!

Can you help me please?

Thx!

donmcint

  • Timothy Bowers
    • Chief Pigeon

    OK, so you are using the Network theme, I think this might look good next to the users name but before the log out, what do you think?

    Lets crack open:

    /wp-content/themes/network/library/components/discover-header.php - Around line 34:

    <?php if ($bp_existed == "true") { ?>
    	<li><a href="<?php echo bp_loggedin_user_domain(); ?>"><?php bp_loggedin_user_fullname() ?></a></li>
    	<li class="logout"><a href="<?php echo wp_logout_url( bp_get_root_domain() ) ?>"><?php _e( 'Log out', TEMPLATE_DOMAIN ) ?></a></li>
    	<li class="avatar"><a href="<?php echo bp_loggedin_user_domain(); ?>"><?php echo bp_core_fetch_avatar( 'item_id='.$bp->loggedin_user->id ); ?></a></li>
    <?php } else { ?>

    And put something like:

    <?php if ($bp_existed == "true") { ?>
    	<li><a href="<?php echo bp_loggedin_user_domain(); ?>"><?php bp_loggedin_user_fullname() ?></a></li>
    <?php  if (bp_friend_get_total_requests_count() == 1) { ?>
    	<li><a href="<?php echo bp_loggedin_user_domain(); ?>friends/requests/?new">One New Friend Request</a></li>
    	<?php } elseif (bp_friend_get_total_requests_count() == 2) { ?>
    	<li><a href="<?php echo bp_loggedin_user_domain(); ?>friends/requests/?new">Your Friend Requests (<?php bp_friend_total_requests_count() ?>)</a></li>
    <?php } ?>
    	<li class="logout"><a href="<?php echo wp_logout_url( bp_get_root_domain() ) ?>"><?php _e( 'Log out', TEMPLATE_DOMAIN ) ?></a></li>
    	<li class="avatar"><a href="<?php echo bp_loggedin_user_domain(); ?>"><?php echo bp_core_fetch_avatar( 'item_id='.$bp->loggedin_user->id ); ?></a></li>
    <?php } else { ?>

    What this is doing is checking how many new friend requests there are, if there are none, then it does nothing, if there is one then it will say "One New Friend Request" and if there is 2 or more it will show "Your Friend Requests (NUMBER)" with the number of requests.

    Hope this helps! ":slight_smile:

  • Timothy Bowers
    • Chief Pigeon

    WAIT!!! YOU SENT ME IS THE CODE IS CUT ON THE RIGHT, CAN YOU SEND ME AN ATTACHMENT?

    I think thats just appearance with code in these forums, when you highlight it all and copy it then it should copy intact?

    CTRL + C - Copy on Microslow Windows
    CMD + C - Copy on Mac

    Let me know. :slight_smile:

  • Timothy Bowers
    • Chief Pigeon

    I just noticed in my code above:

    <?php } elseif (bp_friend_get_total_requests_count() == 2) { ?>

    Should actually be:

    <?php } elseif (bp_friend_get_total_requests_count() >= 2) { ?>

    The difference here is that in the first it is only looking for a message count equal to 2 where as the second is greater or equal to. :slight_smile:

    Sorry about that.

  • Donald McIntyre
    • Design Lord, Child of Thor

    Thank you Tim!

    Contacts = Friends, but I changed the name cause its a business network (but the code needs to be like the original buddypress code with the word friend/s)

    Following/Followers = a buddypress plugin that adds this functionality. If you go to my page on the network for example you will see "Contacts" "Following" "Followers" cause I have this plugin active. Please see it at:

    http://linkedbees.com/members/donmcint

    [EDIT: details removed for your security :slight_smile: ]

    Thank you!!

    Donald (donmcint)

  • Timothy Bowers
    • Chief Pigeon

    You just posted your admin username and password in a public forums, where anyone could see and then access your website. I can access your network admin and everything!

    I've changed your password in the admin to ensure no one can do anything malicious. I'm sorry if this is an inconvenience but its for the safety of your website.

    You need to request yourself a new password from your system.

    I don't currently use the plugin you refer to and so I'm not sure. I might get a chance to look at it next week at some point. :slight_smile:

  • Donald McIntyre
    • Design Lord, Child of Thor

    Thank you Tim! You saved me! Evidently I forgot it was a public forum and was acting like if it was a 2 way conversation!

    Thx again! donmcint

    If you don´t that plugin no worries can you do something like:

    Your Page | Profile | Settings | Contacts (53) | Messages (3) | Sites (4)

    ¿?

    Next week then...

    Thank you donmcint

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.