Find Answers and Get Support › Forums › Gwangi – PRO Multi-Purpose Membership, Social Network & BuddyPress Community Theme › Popular Features › Members Directory › city and age do not appear in profiles
- This topic has 20 replies, 2 voices, and was last updated 6 years, 2 months ago by
Themosaurus.
-
AuthorPosts
-
@themosaurus
- 1 Topics
- 1675 Posts
Hi @chilepower,
The “City”, “Country” and “Age” field displayed on our demo are only available if you use our generated fields.
As described in our setup guide (https://doc.themosaurus.com/finishing-buddypress-setup/), you can generate the default fields by a single click. Only these are the ones that are displayed on member lists and member profile.
If these are not showing on your member directory, the values might be simply have been left empty. However, if these fields are not showing in the admin, it seems that you might have skipped some steps from the setup guide. It’s best to complete every step before going to next otherwise some imports will be broken, like your homepage and directory search forms, for instance.
To solve this, you need to go first to your BuddyPress settings and finish its setup:
This step will help you to generate all the missing profile fields.Your next step will be re-save your homepage and directory search forms.
We use BP Profile Search (https://wordpress.org/plugins/bp-profile-search/) to showcase the profile search feature on our demos.
You can edit the homepage search form by visiting “Users > Profile Search” in your dashboard, where you will find every existing profile search forms.
Just edit your forms and click “Save” without changing anything.Finally, you can test by adding some values to these fields for your test members.
It should solve your issue. ?
Best,
February 12, 2019 at 11:26 #5238@themosaurus- 1 Topics
- 1675 Posts
Hi @chilepower,
Thank you for your great feedback. That’s actually a feature that we’re planning to add in the coming updates as multiple buyers have requested this in some way…
In the meantime, you could solve this by adding the following code snippet to your website:
if ( ! function_exists( 'gwangi_buddypress_member_location' ) ) : /** * Print the HTML for the City and Country XProfile Field in the BP Member Directory. * * @since 1.0.0 */ function gwangi_buddypress_member_location() { if ( function_exists( 'xprofile_get_field_data' ) ) : $city = xprofile_get_field_data( 'City', bp_get_member_user_id() ); $country = xprofile_get_field_data( 'Country', bp_get_member_user_id() ); $allowed_html = array( 'a' => array( 'href' => array(), 'rel' => array(), ), ); if ( ! empty( $city ) && ! empty( $country ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-location"><?php echo wp_kses( $city, $allowed_html ); ?>, <?php echo wp_kses( $country, $allowed_html ); ?></div> <?php endif; endif; } endif;
Simply change
City
using the exact name of your field inxprofile_get_field_data( 'City', bp_get_member_user_id() )
and also change theCountry
inxprofile_get_field_data( 'Country', bp_get_member_user_id() )
.To add this code snippet to your site, we recommend that you use a the Code Snippets plugin (https://wordpress.org/plugins/code-snippets/). If you have never activated this plugin, please read the following post:
Best,
February 12, 2019 at 16:54 #5261DEMENTEParticipant@chilepower- 51 Topics
- 178 Posts
I have 2 more questions
– ready thank you very much worked and is it possible to integrate sex too?
– but it does not appear in the widget of authors, why? http://prntscr.com/mkbi9f
February 13, 2019 at 01:38 #5289@themosaurus- 1 Topics
- 1675 Posts
Hi @chilepower,
1) Could you share with us the exact name for the following fields?
– City
– Country
– Age
– Sex
We will tune the snippet to make it work for you.2) Regarding the author avatar widget, it’s best if you wait for the update as it’s far more complicated and it cannot be solved with a single snippet.
Thank you.
February 13, 2019 at 09:10 #5290@themosaurus- 1 Topics
- 1675 Posts
Hi @chilepower,
Could you add this snippet to the following please? Let’s see if that solve your issue.
if ( ! function_exists( 'gwangi_buddypress_member_birthdate' ) ) : /** * Print the HTML for the Birthdate XProfile Field in the BP Member Directory. * * @since 1.0.0 */ function gwangi_buddypress_member_birthdate() { if ( function_exists( 'xprofile_get_field_data' ) ) : $birthdate_field_id = xprofile_get_field_id_from_name( 'Edad' ); if ( ! empty( $birthdate_field_id ) ) : // Get age using birthdate field value. $birthdate = xprofile_get_field_data( $birthdate_field_id, bp_get_member_user_id() ); $birthdate_field_settings = BP_XProfile_Field_Type_Datebox::get_field_settings( $birthdate_field_id ); if ( 'elapsed' !== $birthdate_field_settings['date_format'] ) : $birthdate_datetime = DateTime::createFromFormat( $birthdate_field_settings['date_format'], $birthdate ); if ( ! empty( $birthdate_datetime ) ) : $age = $birthdate_datetime->diff( new DateTime( 'now' ) )->y; endif; endif; // Get sex field value. $sex = xprofile_get_field_data( 'Sexo', bp_get_member_user_id() ); $allowed_html = array( 'a' => array( 'href' => array(), 'rel' => array(), ), ); // Display age field value. if ( ! empty( $age ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-birthdate"><?php echo wp_kses( $age, $allowed_html ); ?></div> <?php endif; // Display sex field value. if ( ! empty( $sex ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-sex"><?php echo wp_kses( $sex, $allowed_html ); ?></div> <?php endif; endif; endif; } endif;
Could also make sure that your “Edad” field is storing the birthdate and not the age as plain text? Otherwise, you can change the field name in the following code bit:
$birthdate_field_id = xprofile_get_field_id_from_name( 'Edad' );
Best,
February 13, 2019 at 13:57 #5296DEMENTEParticipant@chilepower- 51 Topics
- 178 Posts
now I do not appear anything is deleted the city and age, the first code that you gave me worked perfect but the latter does not work,I just want it to 🙁 appear:
– age
– sex
– city
– and if sexual tendency is possibleFebruary 13, 2019 at 17:24 #5303DEMENTEParticipant@chilepower- 51 Topics
- 178 Posts
I’m using the first code that gave me and age and city appears but I want to also appear sex and sexual orientation http://prntscr.com/mknebs
February 13, 2019 at 17:40 #5304@themosaurus- 1 Topics
- 1675 Posts
Hi @chilepower,
Did you erase the previous code snippet? You actually need to add both, one after the other. This way, “Edad”, “Sexo” and “Ciudad de Residencia” will be displayed on your member cards and profiles.
Yes, we can also sexual tendency if you wish to. How do spell this in Spanish or what is the name of your profile field?
Thank you.
February 14, 2019 at 12:05 #5319@themosaurus- 1 Topics
- 1675 Posts
OK, thank you.
Please try the following:
if ( ! function_exists( 'gwangi_buddypress_member_birthdate' ) ) : /** * Print the HTML for the Birthdate XProfile Field in the BP Member Directory. * * @since 1.0.0 */ function gwangi_buddypress_member_birthdate() { if ( function_exists( 'xprofile_get_field_data' ) ) : $birthdate_field_id = xprofile_get_field_id_from_name( 'Edad' ); if ( ! empty( $birthdate_field_id ) ) : // Get age using birthdate field value. $birthdate = xprofile_get_field_data( $birthdate_field_id, bp_get_member_user_id() ); $birthdate_field_settings = BP_XProfile_Field_Type_Datebox::get_field_settings( $birthdate_field_id ); if ( 'elapsed' !== $birthdate_field_settings['date_format'] ) : $birthdate_datetime = DateTime::createFromFormat( $birthdate_field_settings['date_format'], $birthdate ); if ( ! empty( $birthdate_datetime ) ) : $age = $birthdate_datetime->diff( new DateTime( 'now' ) )->y; endif; endif; // Get sex field value. $sex = xprofile_get_field_data( 'Sexo', bp_get_member_user_id() ); $allowed_html = array( 'a' => array( 'href' => array(), 'rel' => array(), ), ); // Display age field value. if ( ! empty( $age ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-birthdate"><?php echo wp_kses( $age, $allowed_html ); ?></div> <?php endif; // Display sex field value. if ( ! empty( $sex ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-sex"><?php echo wp_kses( $sex, $allowed_html ); ?></div> <?php endif; endif; endif; } endif; if ( ! function_exists( 'gwangi_buddypress_member_location' ) ) : /** * Print the HTML for the City and Country XProfile Field in the BP Member Directory. * * @since 1.0.0 */ function gwangi_buddypress_member_location() { if ( function_exists( 'xprofile_get_field_data' ) ) : $city = xprofile_get_field_data( 'Ciudad de residencia', bp_get_member_user_id() ); $tendency = xprofile_get_field_data( 'Tendencia sexual', bp_get_member_user_id() ); $allowed_html = array( 'a' => array( 'href' => array(), 'rel' => array(), ), ); // Display city field value. if ( ! empty( $city ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-location"><?php echo wp_kses( $city, $allowed_html ); ?></div> <?php endif; // Display tendency field value. if ( ! empty( $tendency ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-tendency"><?php echo wp_kses( $tendency, $allowed_html ); ?></div> <?php endif; endif; } endif;
It’s more complete and contains the four fields to display. Please sure that spelling and case are OK.
Could confirm it works properly now?
Thank you.
February 15, 2019 at 16:10 #5354DEMENTEParticipant@chilepower- 51 Topics
- 178 Posts
no, it does not work it only shows the city and the sexual tendency http://prntscr.com/mll90d 🙁
February 15, 2019 at 17:45 #5356@themosaurus- 1 Topics
- 1675 Posts
Hi @chilepower,
We’re sorry for the inconvenience. This method of trial and error is taking too much and we’re sure that you wish to move forward with your setup.
So, could you please create a new website user for us? If possible with administrator capabilities so we can make a quick check of your settings and test directly to fine tune the given snippet.
You can post the user name and password in your next reply and mark it as private to keep this between us.
Cheers,
February 18, 2019 at 11:03 #5366@themosaurus- 1 Topics
- 1675 Posts
February 19, 2019 at 16:20 #5383@themosaurus- 1 Topics
- 1675 Posts
You’re welcome. ?
Best,
February 20, 2019 at 10:49 #5401 -
AuthorPosts
The topic ‘city and age do not appear in profiles’ is closed to new replies.