Добавление <details></details> к одному конкретному полю Buddypress Xprofile (profile-loop.php) - PullRequest
1 голос
/ 17 июня 2019

Если в специальном поле xprofile с id = 10 есть данные, выведите следующее:

<tr<?php bp_field_css_class(); ?>>

    <td class="label"><?php bp_the_profile_field_name(); ?></td>

    <td class="data"><details><?php bp_the_profile_field_value(); ?></details></td>

</tr>

для всех других полей xprofile с данными вывод должен быть:

<tr<?php bp_field_css_class(); ?>>

    <td class="label"><?php bp_the_profile_field_name(); ?></td>

    <td class="data"><?php bp_the_profile_field_value(); ?></td>

</tr>

Как мне изменить второй while цикл в buddypress profile-loop.php?

<div class="bp-widget <?php bp_the_profile_group_slug(); ?>">

  <h2><?php bp_the_profile_group_name(); ?></h2>

  <table class="profile-fields">

    <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>

      <?php if ( bp_field_has_data() ) : ?>

        <tr<?php bp_field_css_class(); ?>>

          <td class="label"><?php bp_the_profile_field_name(); ?></td>

          <td class="data"><?php bp_the_profile_field_value(); ?></td>

        </tr>

      <?php endif; ?>

      <?php

      do_action( 'bp_profile_field_item' ); ?>

    <?php endwhile; ?>

  </table>
</div>

1 Ответ

0 голосов
/ 17 июня 2019

Я только что решил, используя bp_get_the_profile_field_id():

<div class="bp-widget <?php bp_the_profile_group_slug(); ?>">
  <h2><?php bp_the_profile_group_name(); ?></h2>
    <table class="profile-fields">
      <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
      <?php if ( bp_get_the_profile_field_id() != '273' AND bp_field_has_data()) : ?>
      <tr<?php bp_field_css_class(); ?>>
        <td class="label"><?php bp_the_profile_field_name(); ?></td>
        <td class="data"><?php bp_the_profile_field_value(); ?></td>
      </tr>
      <?php else : ?>
      <tr<?php bp_field_css_class(); ?>>
        <td class="label"><?php bp_the_profile_field_name(); ?></td>
        <td class="data"><details><summary>Anzeigen</summary><?php bp_the_profile_field_value(); ?></details></td>
      </tr>
      <?php endif;?>
...
...