Link To Profile, Messages, Friends, and Settings
-
Hi forum-ers! So in my community section: http://www.tenthavenuenation.com/community/
I have a theme of buttons linking to pages throughout the site. I would like to create buttons (they’re simply images with links) to the logged in user’s Profile, Messages, Friends, and Settings pages. The problem is, how would I go about linking this? Since the URL is different for everyone, I’m not quite sure what to do.Thanks!
-
take a look at this page for details of accessing the logged in user domain:
https://codex.buddypress.org/developer-docs/the-bp-global/
There are also some wrapper functions you can use – e.g. bp_loggedin_user_domain()
but how would i link the URL to an image? Wrap it in HTML image tags and set the URL to “$bp->displayed_user->domain”?
Anyone? I need a link to bits of buddypress.
is this possible?
Yes, you have the BuddyPress function to use to get the URL, and the rest (image links) is basic PHP / HTML and / or CSS.
If you are looking to modify your theme, and don’t have a grounding in PHP / HTML / CSS, it would make sense to do a primer in these first.
I’m not looking to modify the THEME, just create simple links on a page. If I use an HTML image link and insert the link as the buddypress code stated above, that does nothing.
What code would I insert in place of the link URL for creating a simple link?
If you are trying to use PHP code inside a page’s content that’s not going to work… you can’t embed the PHP to form your link in the page content as it won’t get processed.
You need to place it either in a PHP template file (which I assumed you were doing), or find some short code plugin that interprets PHP in a page’s content.
So I installed a PHP in posts/pages plugin, and by using [ php ] and [ /php ] it will turn it on and off. The correct code would be:
[ php ]
displayed_user->domain”>Profile
[ /php ]but that doesn’t work. is there a different sort of link needed for PHP?
Have you used something like firebug / Safari (or Chrome) developer tools to see what code it is actually generating for your link?
What’ve you written above looks nothing like a link — has something been lost in your pasting of code?
As, I said earlier in the thread… this is fairly basic PHP / HTML stuff, and not really a BuddyPress question anymore.
Edit:
`<a href="displayed_user->domain?>”>Profile` is how you would write it in a template fileso if i need to use a template file, where would i put it and how would i get it so that i can link to it on a page? using the code you put above in an “allow php” setting gives me a 404 error on the page.
To learn about template files in WordPress, your best starting point is the WordPress docs: https://codex.wordpress.org/Template_Hierarchy
Okay, that works, and when I place it correctly in the page template I get a link to “profile” text. The problem being that it doesn’t do anything – it only refreshes the page.
Why is the code only refreshing the page it’s on?
- The topic ‘Link To Profile, Messages, Friends, and Settings’ is closed to new replies.