Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] user page tab with a link to another site

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

  • danbp
    Participant

    @danbp

    Hi,

    try this (add to bp-custom.php):

    function add_profiles_link_to_page(){
    
    	if ( bp_is_profile_component() || bp_is_user() ) {
    
    	// allow link to appear only to loggedin user
    	/*if ( !is_user_logged_in() )
    		return false; */
    
    	// tabed internal link : /internal link/page name/
    	//$link =  bp_get_root_domain() . '/book/';
    
    	// tabed external link
    	$link =  "https://www.amazon.com/";
    	
    	?>
    		<li><a href="<?php echo $link; ?>"><?php printf( 'My Books' ); ?></a></li>
    	<?php  
    	}
    }
    add_action( 'bp_member_options_nav', 'add_profiles_link_to_page' );

    Merida
    Participant

    @magicalworlddolls

    Thanks for the reply. I did everything according to your instructions.
    but when you open the site gives an error
    Parse error: syntax error, unexpected '}', expecting end of file in /home/user..../site/wp-content/plugins/bp-custom.php on line 18

    how to fix? thank you in advance.


    danbp
    Participant

    @danbp

    The snippet was tested before publication and it works.
    Have you removed something inside ? Have you removed/added something before/after the function ?

    Note also that bp-custom file use an opening php tag on the very first line but doesn’t use a closing php tag at the end of file. That explains why the snippet contains a closing php tag before the line containing the <li> and an opening php tag after.

    Triple check your file!


    lesanis
    Participant

    @lesanis

    Hello,

    Very usefull code, I have added it in my website and it’s working! Is there a way to make it work with dynamic links like friends followers etc? And is there a way to make it work generally for all user’s profiles and not only if a user is logged in?

    Thank you!!


    Merida
    Participant

    @magicalworlddolls

    Default I did not have the file bp-custom.php

    I created this file in /home/user/site/wp-content/plugins/bp-custom.php

    And then in the bp-custom.php file (it was empty), add your code.


    danbp
    Participant

    @danbp

    @magicalworlddolls,

    Read codex page about bp-custom and my answer. You need an opening php tag at the first line of the file.


    @lesanis
    ,

    what you’re asking for is in the snippet. Read the comments (lines starting by //).
    The restriction for logged-in users is already deactivated. So by default, the function run’s for ALL visitors.
    To get dynamic links to friends, search the forum, you have many topics to find containing the right solution. Search for bpfr_, it will bring up a lot results containing snippets. And if not enough, check in Codex.


    Merida
    Participant

    @magicalworlddolls

    Thank you very much! All ok.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] user page tab with a link to another site’ is closed to new replies.
Skip to toolbar