Skip to content

Instantly share code, notes, and snippets.

@moskalukigor
Forked from modemlooper/php
Created April 7, 2021 13:11
Show Gist options
  • Select an option

  • Save moskalukigor/e5a4bef8eb101056e05302edc76f88e6 to your computer and use it in GitHub Desktop.

Select an option

Save moskalukigor/e5a4bef8eb101056e05302edc76f88e6 to your computer and use it in GitHub Desktop.

Revisions

  1. Ihor renamed this gist Apr 7, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @modemlooper modemlooper created this gist Jan 29, 2016.
    48 changes: 48 additions & 0 deletions php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    <?php
    /**
    * Plugin Name: BP Add Page
    * Plugin URI: https://webdevstudios.com
    * Description: Example on adding a page to BuddyPress profiles
    * Author: WebDevStudios
    * Author URI: https://webdevstudios.com
    * Version: 1.0.0
    * License: GPLv2
    */


    /**
    * adds the profile user nav link
    */
    function bp_custom_user_nav_item() {
    global $bp;

    $args = array(
    'name' => __('Portfolio', 'buddypress'),
    'slug' => 'portfolio',
    'default_subnav_slug' => 'portfolio',
    'position' => 50,
    'screen_function' => 'bp_custom_user_nav_item_screen',
    'item_css_id' => 'portfolio'
    );

    bp_core_new_nav_item( $args );
    }
    add_action( 'bp_setup_nav', 'bp_custom_user_nav_item', 99 );

    /**
    * the calback function from our nav item arguments
    */
    function bp_custom_user_nav_item_screen() {
    add_action( 'bp_template_content', 'bp_custom_screen_content' );
    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
    }

    /**
    * the function hooked to bp_template_content, this hook is in plugns.php
    */
    function bp_custom_screen_content() {

    echo '<p>The custom content.
    You can put a post loop here or something else</P>';

    }