Would you be looking to use an existing label or add a new one, which page?
We want to add a new label. The page would be the Edit Profile page.
What you can do is overload that pages, the source file is plugins/buddypress/bp-templates/bp-legacy/buddypress/members/single/profile/edit.php
Copy this file to themes/your-child-theme/buddypress/members/single/profile/edit.php
you can then edit this page to insert your label where you need.
venutius – thank you.
I am not a WordPress expert, so I need a little more guidance. My guess is that the call to bp_the_profile_field returns the current edit field and that I could create an if clause that would insert some HTML if the field ID (or label) matches the one where I want my label inserted. But this is just a guess – can you please point me in the right direction?
Yes that sounds about right, the page is doing a loop printing out the profile fields, so you could add an if statement dependent on the field name.
if ( 'Name' == bp_get_the_profile_field_name() ) {
//insert label
}
Sorry for being slow…
I looked at the source for the page and found that the ID for the field is field_821. I then inserted three lines of code into the edit.php file as shown below (the first line is existing code, at line 22, shown for reference)
<div<?php bp_field_css_class( 'editfield' ); ?>>
<?php if ( 'field_821' == bp_get_the_profile_field_name() ) : ?>
<p>My label here</p>
<?php endif ?>
Note: I also tried with the
And yes, I want this label to appear above the field name. I also realize that simply using <p> may not provide the desired formatting, but to goal now is simply to get the test to appear. What am I doing wrong?
Small typo in your code, you did not close the div tag, also I note you don’t close the div. When a field has a name like field_821 I’d be worried that it was being dynamicaly incremented for each user/instance so may note be the same for all users. Other than that it’s difficult to suggest anything without seeing your setup direct.
<div><?php bp_field_css_class( 'editfield' ); ?>>
<?php if ( 'field_821' == bp_get_the_profile_field_name() ) : ?>
<p>My label here</p>
<?php endif ?>
Thanks again for the help! This post, https://buddypress.org/support/topic/how-to-customize-the-order-of-fields-of-registration/, led me to the answer: the function bp_get_the_profile_field_name() returns the ‘friendly’ name of the field, i.e., that which is defined in wp-content\plugins\<my-plugin>\include\users\profile.php as the label parameter for the field.
Great! glad you sussed it.