Hello
Please how can I add two new custom buttons to the buddypress profiles page (bp_is_profile) were the other buttons are displayed like the public message and private message buttons. This buttons will be custom links to any page and should only appear in the profile header of the current logged in user. The buttons will have text and links below
1. Write a new article — This button will link to https://www.website.com/publish/
2. Post a free advert — This button will link to https://www.website.com/advertise/
Thanks
Hello Tosin,
Thank you for posting. Please try the follwoing code it will add two on loggedin user profile with “BuddyPress Nouveau” template active
/** * Add two buttons * * @param array $buttons Buttons. * * @return array */ function buddydev_add_custom_buttons( $buttons ) { if ( ! bp_is_my_profile() ) { return $buttons; } $buttons['new_article'] = array( 'id' => 'buddydev_new_article', 'component' => 'members', 'must_be_logged_in' => true, 'button_element' => 'a', 'link_text' => __( 'Write a new article' ), 'button_attr' => array( 'href' => esc_url( 'https://www.website.com/publish/' ), 'title' => __( 'Write a new article' ), ) ); $buttons['new_advert'] = array( 'id' => 'buddydev_new_advert', 'component' => 'members', 'must_be_logged_in' => true, 'button_element' => 'a', 'link_text' => __( 'Post a free advert' ), 'button_attr' => array( 'href' => esc_url( 'https://www.website.com/advertise/' ), 'title' => __( 'Post a free advert' ), ) ); return $buttons; } add_filter( 'bp_nouveau_get_members_buttons', 'buddydev_add_custom_buttons' );
Please let me know if it helps or not.
Regards
RaviHello Tosin,
Try the following code.
/** * Add custom button on user own profile */ function buddydev_add_custom_buttons() { if ( ! bp_is_my_profile() ) { return; } $new_article_button_args = array( 'id' => 'buddydev_new_article', 'component' => 'members', 'must_be_logged_in' => true, 'block_self' => false, 'link_href' => esc_url( 'https://www.website.com/publish/' ), 'link_text' => __( 'Write a new article' ), ); $new_advert_button_args = array( 'id' => 'buddydev_new_advert', 'component' => 'members', 'must_be_logged_in' => true, 'block_self' => false, 'link_href' => esc_url( 'https://www.website.com/advertise/' ), 'link_text' => __( 'Post a free advert' ), ); echo bp_get_button( $new_article_button_args ); echo bp_get_button( $new_advert_button_args ); } add_action( 'bp_member_header_actions', 'buddydev_add_custom_buttons' );
Regards
RaviHello Tosin,
Please make sure in your “member-header.php” template has this action “bp_member_header_actions”. This is working for me.
Regards
Ravi
You must be logged in to reply to this topic.