bp_core_new_nav_item() not working to create new navigation item under “my profile” tab
-
So I’m trying to add a new navigation under the “my profile” tab in buddypress once a user logs in. I created and am using the bp-custom.php file in my wp-content/plugins directory (outside of the buddypress directory) to insert the custom code. This is what I have and it’s not working simply causes
This is the code I have in bp-custom.php file (and that’s all I have!)
`<?php
//place for custom buddypress functions
bp_core_new_nav_item(
array(
‘name’ => ‘feedback’,
‘slug’ => ‘Feedback’
));?>`
I got the following error in my browser.
Server error
The website encountered an error while retrieving http://tugora.com/. It may be down for maintenance or configured incorrectly
I am using the frisco for buddypress theme, not sure if this is part of my problem.
What can I do to fix this error? (move bp-custom? misuse of function? theme incompatibility?) Thanks in advance!
-Alex
-
You need to first look in your web server’s PHP error log, and see what it says.
Thanks for the response Paul. The php error log says the following
stderr: PHP Fatal error: Call to undefined function bp_core_new_nav_item ()
This of course means the function can’t be found. What do I need to do for the buddypress function to be recognized? Thanks again!That error is due to the missing $bp global.
>So I’m trying to add a new navigation under the “my profile” tab
Do you mean in the admin bar at the top?
Or on profile pages under ‘Profile’ in the ‘Activity Profile Messages’ etc nav ?if it’s the latter, you want to a subnav item, not a nav item.
Try this (which assumes you don’t know about the other functions needed) :`
add_action( ‘bp_setup_nav’, ‘add_feedback_subnav_tab’, 100 );
function add_feedback_subnav_tab() {
global $bp;
bp_core_new_subnav_item( array(
‘name’ => ‘Feedback’,
‘slug’ => ‘feedback’,
‘parent_url’ => trailingslashit( bp_loggedin_user_domain() . ‘profile’ ),
‘parent_slug’ => ‘profile’,
‘screen_function’ => ‘profile_screen_feedback’,
‘position’ => 50
)
);
}// show feedback when ‘Feedback’ tab is clicked
function profile_screen_feedback() {
add_action( ‘bp_template_content’, ‘profile_screen_feedback_show’ );
bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
}function profile_screen_feedback_show() {
echo “Feedback Screen”;// call your feedback template
//locate_template( array( ‘feedback-profile.php’ ), true );}
`
- The topic ‘bp_core_new_nav_item() not working to create new navigation item under “my profile” tab’ is closed to new replies.