BuddyDev

Search

[Resolved] Plugin Help: Link Page to Groups

  • Participant
    Level: Initiated
    Posts: 9
    Alex on #46055

    Hi,

    I want to use this plugin to display a link to my “Rules” page on every group.

    Is there a way to change the default, so that it always links to a specific page (rather than the site admin having to edit the group to change the linked page each time).

    Many thanks
    Alex

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #46060

    Hi Alex,
    Thank you for the question.

    Please disable the plugin and use this code instead.

    
    
    /**
     * Adds some page links to group nav.
     */
    function buddydev_custo_add_pages_to_group_nav() {
    
    	$group_id = bp_get_current_group_id();
    
    	if ( ! $group_id ) {
    		return;
    	}
    
    	$page_ids = [ 1, 2, ]; // these are page ids.
    
    	foreach ( $page_ids as $page_id ) {
    		$post = get_post( $page_id );
    		if ( ! $post ) {
    			continue;
    		}
    		echo '<li class="bp-linked-group-page"><a href="' . get_permalink( $post ) . '">' . get_the_title( $post ) . '</a></li>';
    	}
    }
    
    add_action( 'bp_group_options_nav', 'buddydev_custo_add_pages_to_group_nav' );
    

    Please change the $page_ids with the actual page ids(one or more).

    You can put this code in your theme’s functions.php or in wp-content/plugins/bp-custom.php or use it with any code snippet manager.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 9
    Alex on #46063

    Hi, thanks for supplying the code. However, while the plugin correctly inserted the link, the provided code doesn’t work for me. I’m using the Youzify plugin if that could be the reason? thanks for your help, Alex

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #46071

    Please make sure that you have copied the code from this forum post and not from email reply.
    Also, make sure that the page with the ids exist.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 9
    Alex on #46079

    It worked, thanks so much, really appreciate your help!

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #46080

    You are welcome.

The topic ‘ [Resolved] Plugin Help: Link Page to Groups’ is closed to new replies.

This topic is: resolved