Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom msg in own profile


  • Ron Ashman
    Participant

    @fakurkr

    Hi,

    I’ve been looking without luck on how to add a message to one’s own profile page. I have been able to add it for everyone but this msg should be visible only when seeing profile of currently logged in user.

    The msg is something like “The base info is only visible to you. Second group you can manage what others see”. So that’s why I should see this msg only if I am lookin at my own profile.

    I know this is out of scope of support so I don’t expect an straight answer, just maybe someone who can point me on the right direction of what I’d bee looking for.

    Thanks.

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

  • shanebp
    Moderator

    @shanebp

    I have been able to add it for everyone…

    How did you do that?
    Wrap it in a conditional: if ( bp_is_my_profile() ) {...}

    http://hookr.io/functions/bp_is_my_profile/


    Ron Ashman
    Participant

    @fakurkr

    Hello,

    Thank you for answering shanebp.

    I did it with translation files, so simple and dumb for someone like me who knows very very little about PHP.

    Anyway, thank you! Your suggestion lead me to the right track and I did it.

    For anyone wondering how to do it:
    Overload (search in forum) a template for profile.php and add wherever you need the following:

    <?php if ( bp_is_my_profile() )
    echo "Your custom text with HTML code or whatever"
    ?>

    Thanks again! 😀


    danbp
    Participant

    @danbp

    Hi @fakurkr,

    the other solution is to use the existing action hooks existing in each BP template.
    Templates are the files stored in bp-templates/bp-legacy/buddypress/ directory.

    For example if you read the code in buddypress/members/single/member-header.php, you will find not less than 6 action hooks, only for the profile header. This means 6 potential places where to add something like a message.

    Th other avantage of this method is that you don’t need to modify any template and that you stay independant from any theme, because you will use a function from bp-custom.php

    In your case, adding a message on user’s profile with help of a function like this:

    function bpfr_my_message_on_profile () {	
    
    	echo 'Your custom text with HTML code or whatever'; 
    
    add_action( 'bp_before_member_header_meta', 'bpfr_my_message_on_profile' );

    And because it is only fired on a profile header, you don’t need the conditional (my_profile). You can of course add other conditions. Sky is the limit !

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar