Skip to:
Content
Pages
Categories
Search
Top
Bottom

Create html image link to logged in user's profile

  • @flexclique

    Participant

    I am trying to create a page to act as a UI dashboard with custom image links to the main parts of Buddypress. I have searched everywhere and can’t figure out how to create a link to the user profile page or any of the dynamic areas for that matter.

    Thanks for any help!

Viewing 11 replies - 1 through 11 (of 11 total)
  • @matt-mcfarland

    Participant

    Hi there,

    IF you’re familiar with wp_nav_menu() (see wp codex) bp_nav_menu() behaves the same way, and that’s the easiest way, I”ve found, to customize it. I hope this helps

    @matt-mcfarland

    Participant

    If you just want to get a link to the current user that is logged in’s profile, and you’re using permalinks, this will work:

    <a href="/members/<?php echo wp_get_current_user()->user_login; ?>/profile/">
    //your html here
    </a>

    @flexclique

    Participant

    I’m using permalinks…

    What I’m trying to accomplish is: I have an image, this image will be on a standard wordpress page and I want a logged in user to click on the image and be taken to their profile page.

    @flexclique

    Participant

    I put this in the wordpress page on the text tab…

    <a href="/members/<?php echo wp_get_current_user()->user_login; ?>/profile/">
    <img src="http://mydomain.com/images/myprofile.png>
    </a>

    Nothing renders. I saw where you can’t run php from a page… could this be my issue?

    @matt-mcfarland

    Participant

    Great! the code I posted above should work then. I havent tested it but that will work if you’re using permalinks. becuase bp will do members/user_login/profile/ by default so you jsut need their user_login which you can ECHO out via the PHP using wordpress alone.

    @matt-mcfarland

    Participant

    You’re putting that in the page itself? Yeah you have to use a php file.

    You could use hanacode plugin https://wordpress.org/plugins/hana-code-insert/ to insert php

    @matt-mcfarland

    Participant

    Also just take a look at this: https://codex.wordpress.org/Function_Reference/wp_get_current_user;

    $current_user = wp_get_current_user();

    Then you can do:

    $current_user->user_login instead of wp_get_current_user()->user_login just in case. altho I think both would work.

    @matt-mcfarland

    Participant

    Or you could just make your own theme and throw in the php 😉

    The following tutorial changed my life forever and I’ll never look back to the days I used much of the dashboard page editor at all:
    The ThemeShaper WordPress Theme Tutorial: 2nd Edition

    @shanebp

    Moderator
    <a href="<?php echo bp_loggedin_user_domain; ?>profile/">
    <img src="http://mydomain.com/images/myprofile.png>
    </a>

    @flexclique

    Participant

    Well, I’m making progress…

    I installed the plugin and now the code displays on the page… not executed, but just as it was typed. So it’s similar to putting bat ticks around it in this forum. I even checked the box that says allow execution of php in the plugin’s settings.

    @flexclique

    Participant

    Thank you! I got it sorted out now… there were actually 2 places in the plugin that you had to check to execute the php.

    I should be in great shape now!

    I appreciate the help!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Create html image link to logged in user's profile’ is closed to new replies.
Skip to toolbar