Info
- 7 posts
- 3 voices
- Started 4 years ago by fel64
- Latest reply from fel64
- This topic is not resolved
Profile Tabs
-
- Posted 4 years ago #
How do you add a tab to the three tabs - "Profile", "Edit" and "Favourites" - visible only in the profile? I want to add a tab for the avatar and am fairly sure there's a hook
bb_profile_menubut I'm not sure what to do with it. The API certainly supports adding them, the code's there, but I'm not sure how to do it. Anyone know? -
- Posted 4 years ago #
Look at the function global_profile_menu_structure.
You just need to create a function that pulls in the array variable $profile_menu as a global. Then add to that array in the manner specified in the comments of the function global_profile_menu_structure.
Should be downhill from there.
p.s. Would be nice if you could add an entry for it at bbPulp when you are done.
-
- Posted 4 years ago #
Cheers Sam, that's definitely the way to do it, but I can't quite make it work. Adding the tab is easy, but following the link dumps you on the front page (if using
add_profile_tab()) or in your profile (if adding the tab manually).function felavatartab() { global $profile_menu, $profile_hooks; $profile_tab = array(__('Avatar'), 'edit_profile', 'moderate', 'avatar-upload.php', 'avatar'); $profile_menu[] = $profile_tab; if ( can_access_tab( $profile_tab, bb_get_current_user_info( 'id' ), $user_id ) ) $profile_hooks[bb_tag_sanitize($profile_tab[4])] = $profile_tab[3]; } add_action( 'bb_profile_menu', 'felavatartab' );OR
function felavatartab() { add_profile_tab(__('Avatar'), 'edit_profile', 'moderate', 'avatar-upload.php'); } add_action( 'bb_profile_menu', 'felavatartab' );I've got the file
avatar-upload.phpin my root directory, which loads the templateavatar.php. If instead you giveavatar.phpas your argument the tab doesn't show up at all.See it here. Any idea?
-
- Posted 4 years ago #
I tested the second method on the latest build and it passes the bb_repermalink tests and loads.
I tried using standard URLs and both types of permalinks.
I didn't try to load a template. I used a file called avatar-upload.php containing the following:
<?php require_once('./bb-load.php'); bb_repermalink(); // The magic happens here. echo 'test'; ?>My test plugin contained:
<?php /* Plugin Name: Test for fel64 Plugin URI: Description: Test profile tab addition Author: Scooby Doo Version: 0.0.1 Author URI: */ $bb->debug = 1; function felavatartab() { add_profile_tab(__('Avatar'), 'edit_profile', 'moderate', 'avatar-upload.php'); } add_action( 'bb_profile_menu', 'felavatartab' ); ?> -
- Posted 4 years ago #
Should really have been more familiar with the code - there's a check to see if it's the correct file, otherwise it simply redirects to the front page. Getting rid of that made it work.
Thanks for all your help, Sam! :D
-
- Posted 4 years ago #
Aha! Thank you Sam! As fel has already discovered I abandoned any attempt at having "Upload Avatar" as a profile tab. It's definitely going into the next version.
-
- Posted 4 years ago #
Note that you will have to get rid of the filename check and that all that $user_id business is unnecessary and stopped my script executing. Just grab the global $user.
-
You must log in to post.