BuddyDev

Search

[Resolved] Buddypress Anonymous Plugin Quick Question

  • Participant
    Level: Initiated
    Posts: 9
    Brayden on #1401

    Hi Brajesh,

    I am using your BP Anonymous Plugin and I ran into a problem with it. Posting anonymously works perfectly but on my website I have the option to view the profile of users who post updates. When I post an update as anonymous it shows my name in the profile section.

    Here are some screenshots.

    When I post a non-anonymous update: http://s4.postimg.org/l9omvni4d/profile.png

    When I post a anonymous update: http://s28.postimg.org/9g6qcyvwt/profile2.png

    Code I use to display the view profile: http://s9.postimg.org/ns5e97p6n/codeused.png

    Is there anyway to get around this problem?

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #1402

    Hi Bryden,
    Thank you for asking. Since we are only filtering based on activity, it is not filtering your bare user links.

    the simple solution is to use a condition like this

    
         $activity_id = bp_get_activity_id();
        
        if( !bp_is_anonymous_activity(  $activity_id ) ) {
       echo "View <span> {$xprofile_user} Profile";
    }
    
    

    Since I have seen incomplete code, that view and span may not be necessary inside the condition. Please update it as it suits.

    Hope that helps.

    `

  • Participant
    Level: Initiated
    Posts: 9
    Brayden on #1405

    Thank-you for the fast response.

    Here is the entire line of code:

    
    Obfuscated code block removed by- @sbrajesh
    

    Where exactly would I add your code in there? I am fairly new with php so any guided help would be appreciated, thanks.

  • Participant
    Level: Initiated
    Posts: 9
    Brayden on #1406

    Since the code didn’t format well in the comment I have made a screenshot.

    http://s3.postimg.org/8astxolhf/newcode.png

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #1410

    Hi Bryden,
    Sorry about the trouble.
    Can you please tell me what is this $xprofile_user?

    PS: to post the code please use backticks(`)

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 9
    Brayden on #1416

    ‘ $xprofile_user = strtok(xprofile_get_field_data(‘name’, $user_id), ” “).’\’s’; ‘

    The $xprofile_user is just getting the ‘name’ field you chose on registration.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #1423

    Hi Brayden,
    Apologies for the delayed reply.
    Please use this code instead

    
    $activity_id = bp_get_activity_id();
        
    if( ! bp_is_anonymous_activity(  $activity_id ) ) :?>
    
    	<a href="<?php bp_activity_user_link();?>" <span class="text-primary"><i class="fa fa-paper-plane"></i> View </span><?php echo $xprofile_user;?> Profile</a>
    <?php endif;?>
    
    

    Here we are only showing the link if the user is not anonymous, otherwise nothing will be shown.

  • Participant
    Level: Initiated
    Posts: 9
    Brayden on #1441

    If the user is anonymous how would I make it say ‘Anonymous User’ because right now there is a blank space where the user’s name would be.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #1450

    Hi Brayden,
    you can update that code with this

    
    $activity_id = bp_get_activity_id();
        
    if( ! bp_is_anonymous_activity(  $activity_id ) ) :?>
    
    	<a href="<?php bp_activity_user_link();?>" <span class="text-primary"><i class="fa fa-paper-plane"></i> View </span><?php echo $xprofile_user;?> Profile</a>
    <?php else :?>
    	<a href="#"><span class="text-primary"><i class="fa fa-paper-plane"></i> </span> Anonymous </a>
    <?php endif;?>
    
    

    Also, you can modify it as you need.

    Hope that heps.

  • Participant
    Level: Initiated
    Posts: 9
    Brayden on #1469

    Thank-you so much, this worked perfectly.

The topic ‘ [Resolved] Buddypress Anonymous Plugin Quick Question’ is closed to new replies.

This topic is: resolved