Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: extending groups slug with images


Burt Adsit
Participant

@burtadsit

If bp can’t resolve the url to something covered in nav instead of 404’ing out it send you to your profile. The bp nav mechanism is the url dispatch mechanism.

An example:

$profile_link = $bp->loggedin_user->domain . $bp->contents->slug . '/' ;
bp_core_add_subnav_item($bp->contents->slug, 'my-contents' , __( 'Personal',
'oci-contents' ), $profile_link, 'oci_screen_profile_my_contents');

Lets say that $bp->contents->slug is the slug I’ve set up for use in my component which is ‘contents’. Making that call above tells bp to listen for this url structure in the member profile:

/members/burtadsit/contents/my-contents

When the $bp->current_component: /members/burtadsit/(contents)/my-contents and the $bp->current_action /members/burtadsit/contents/(my-contents) is the url then trigger the function oci_screen_profile_my_contents().

What you do in oci_screen_profile_my_contents() is, amongst other things display the template that you want displayed to the user. That can display images or do user input. Whatever you decide it does.

function oci_screen_profile_my_contents() {
global $bp, $bp_unfiltered_uri;

if (!bp_is_home())
return;

if ( isset( $_POST['submit_save_profile_tags'] )) {
$item = oci_get_user_item();
if ($item){
$node = oci_save_global_tags($item->id, '/' . OCI_TAG . '/' . OCI_USER);
}
$path = oci_get_the_profile_action();
bp_core_redirect($path);
}
bp_core_load_template( 'oci-contents/profile/my-contents' );
}

What my function does above is to listen for stuff being submitted by the ‘my-contents’ form and process it. If the user hasn’t hit ‘Save’ then we are just displaying the form for the first time to the user. At the bottom it drops through and just displays the template ‘my-contents’. Default behavior.

Skip to toolbar