0

I am trying to echo buddypress member link. I cannot echo code because it is within html code. See code below, php code within a link, but this link and list are within php code. I know I did something wrong, php code inside html, and html inside php.

<?php
foreach ($rows as $query_row) {
    $member_id=$query_row['user_id'];

    echo"<ul class='display_box' id='display_box'>";

    echo "<li><a href='<?php echo bp_core_get_user_domain( $member_id ); ?>'>
   <?php echo bp_core_fetch_avatar ( array( 'item_id' => $member_id, 'type' => 'thumb' ) ); ?> 
 <?php echo bp_core_get_user_displayname( $member_id ); ?>
           </a></li>";

                  echo"</ul>";



}//foreach
?>
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
conan
  • 1,327
  • 1
  • 12
  • 27

2 Answers2

2

Change:

 echo "<li><a href='<?php echo bp_core_get_user_domain( $member_id ); ?>'>......

To:

 echo "<li><a href='" . bp_core_get_user_domain( $member_id ) . "'>" .
bp_core_fetch_avatar ( array( 'item_id' => $member_id, 'type' => 'thumb' ) ) .  
bp_core_get_user_displayname( $member_id ) . "</a></li>";
     echo"</ul>";

For example.

Ezra Morse
  • 131
  • 1
  • 4
2

You're already in PHP code. When you're trying to do this:

echo "Some text <?php echo $someValue; ?> more text";

What you meant is this:

echo "Some text " . $someValue . " more text";

or perhaps this:

echo "Some text $someValue more text";

(if it's just a variable that can be auto-interpreted)

If you echo code, you're doing just that... echoing it. If you want to execute code, don't put it in a string. Just execute it.

David
  • 208,112
  • 36
  • 198
  • 279