Skip to:
Content
Pages
Categories
Search
Top
Bottom

use $varibal as parent url in bp_nav


  • yadigit
    Participant

    @yadigit

    Hi guys. I hope someone can help me out here. I got this to work for the most part but im still having problems with reloading the page.
    I created a new profile sub nav.
    Ex

    
    function my_bp_nav_adder()
    {
    bp_core_new_nav_item(
       array(
         'name' => __('Wall Posts', 'buddypress'),
         'slug' => 'hidden-truths',
         'parent_url' => $bp->loggedin_user->domain . $bp->groups->slug . '/',
         'position' => 10,
         'show_for_displayed_user' => true,
         'screen_function' => 'my_hidden_truths',
         'item_css_id' => 'all-conversations',
         'default_subnav_slug' => true,		
       ));
      print_r($wp_filter); 
    }
    
    function my_hidden_truths() {
     add_action( 'bp_template_title', 'truth_wall_header_title' );
     add_action( 'bp_template_content', 'truth_wall_content' );
     bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/bpwall/index' ) );
    }
    
    function truth_wall_header_title() {
    #stuff
    }
    
    function truth_wall_content() {
    #stuff
    } add_action( 'bp_setup_nav', 'my_bp_nav_adder' );

    It works. But not 100%
    This is what im aiming to do.
    Eg..
    $varibel = $_POST['somedata'];
    (POST[‘somedata’] will be data drawn from the database. a number to be exact.)

    
         'name' => __('Wall Posts', 'buddypress'),
         'slug' => 'hidden-truths',
         'parent_url' => $bp->loggedin_user->domain . $bp->groups->slug . '/post/$varible',
         'position' => 10,
         'show_for_displayed_user' => true,
         'screen_function' => 'my_hidden_truths',
         'item_css_id' => 'all-conversations',
         'default_subnav_slug' => false,		
       ));
    

    I got it to work, but I when I refresh the page. I get a 404. I understand that the data is not sticking and once you refresh the page, the data gets released..

    Is there anyway to use data from the database and enter it in the slug?

    Kinda like what it’s like for the members url. It’s not hard coded and it’s data drawn from the database.
    /../members/admin/
    /../members/users1/
    /../members/users2/
    Regardless of what user you go to, the same data (for the most part) is loaded, but if you change the url from users1 to admin, The data for admin is loaded.

    I do apologize if this isn’t enough information.
    Thank you!

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

  • shanebp
    Moderator

    @shanebp

    You put your variable in a string.
    Try
    'parent_url' => $bp->loggedin_user->domain . $bp->groups->slug . '/post/' . $variable,

    You should also have this at the top of your function: global $bp;


    yadigit
    Participant

    @yadigit

    It works. But, there’s still a slight problem. When I refresh the page, I get a 404.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘use $varibal as parent url in bp_nav’ is closed to new replies.
Skip to toolbar