Skip to:
Content
Pages
Categories
Search
Top
Bottom

Creating new pages/tabs on groups/profile page – this isn't working! :(

  • Hi there.

    This is the code I’m using:

    <?php
    /*
    Plugin Name: Groups Links
    Description: Add links to the groups page.
    Author: Thomas Clayson
    */
    function add_groups_links_page(){
    global $bp;
    
    $groups_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/';
    
    bp_core_new_subnav_item( array(
    'name' => 'Links',
    'slug' => 'links',
    'parent_url' => $groups_link,
    'parent_slug' => $bp->groups->slug,
    'screen_function' => 'group_links_function_to_show_screen',
    'position' => 35,
    'user_has_access' => $bp->groups->current_group->user_has_access,
    'item_css_id' => 'group-links' ) );
    }
    add_action( 'wp', 'add_groups_links_page');
    
    function group_links_function_to_show_screen() {
    
    add_action( 'bp_template_title', 'group_links_function_to_show_screen_title' );
    add_action( 'bp_template_content', 'group_links_function_to_show_screen_content' );
    
    $templates = array('groups/single/plugins.php','plugin-template.php');
    if( strstr( locate_template($templates), 'groups/single/plugins.php' ) ) {
    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'groups/single/plugins' ) );
    } else {
    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
    }
    }
    
    function group_links_function_to_show_screen_title() {
    echo 'Links';
    }
    
    function group_links_function_to_show_screen_content() {
    echo "Rawr";
    }
    
    ?>

    but it’s not working! :( The tab comes up on the groups page (Links), but when you click it (even though it links to …/groups/the-group-slug/links) properly, as it should, the content dosen’t come up, and instead it redirects to the homepage! :(

    What am I doing wrong?! The group-documents plugin is working properly, and I’ve been trying to copy that code as much as possible as well as anything I could find on the internet. As far as I can see I haven’t done anything wrong….

    Thanks for any help you can give me.

Viewing 2 replies - 1 through 2 (of 2 total)

  • Virtuali
    Participant

    @gunju2221

    What do you want to be in the links page?

    Use the buddypress links plugin https://wordpress.org/extend/plugins/buddypress-links/ it adds that tab to groups

    I’ve already tried to install that, but its not coming up in my plugins page! :( I don’t know why, but 60% of plugins don’t show up in my plugins page when I install them. That plugin is one of them. I can install it, then if I click “activate” it tells me that there isn’t a header for the plugin. If I go back to the plugins page then it dosen’t show up in the list either (so I can’t activate it!). Any idea how to fix this? That is why I’m trying to do it myself.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Creating new pages/tabs on groups/profile page – this isn't working! :(’ is closed to new replies.
Skip to toolbar