Support only during business hours : Monday to friday, from 8:30 am – 5:30 pm CEST

Due to the decrease in our staff due to vacations, our response time may be longer.

Be sure we're doing our best to manage your topic as soon as possible.

Display City on User Profile

This topic is resolved
Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • prince
    Participant
    • 12 Topics
    • 19 Posts
    @prince22

    Hi there,

    First all of this is an outstanding theme. Great work!

    On the demo you have the city showing for the user profile under “meet our active members” or when you search for members.

    How can I display city for the user profile?

    On my site it currently displays name for the user profile but it doesn’t show any other information.

    Thanks for your help!

    Themosaurus
    Keymaster
    Themosaurus Support
    • 1 Topics
    • 1676 Posts
    @themosaurus

    Hi prince,

    Thank you for the kind words! ?

    From what we’ve understood, it seems that you 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.

    First, you need to go to your BuddyPress settings and finish its setup:

    Finishing BuddyPress Setup

    This step will help you to generate all the missing profile fields, like City.

    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, to learn more about profile search forms, please read also the following posts:

    Add new fields to homepage search form

    My profile search form seems to be broken

    This should solve your issue.

    Best regards,

    prince
    Participant
    • 12 Topics
    • 19 Posts
    @prince22

    Hi there,

    I’m back working on this but I wasn’t able to display city on the members directory page. It currently shows the name of the user under the profile picture. On the demo there’s city and age. I’m only interested in having the name and city for the user profile on members directory page.
    I have followed the steps below as you mentioned above:
    – Installation of Buddypress set-up complete but I did not do the default fields generation. I added my own fields including city. Under profile fields have Name, About, City, etc. I also re-ordered these to show city under the member directory but didn’t work.
    – I added BP Profile Search and it works.

    Currently the members directory page shows the user profile picture and the name below. But I would like to display city below the name like you have shown on the demo here but no age: https://youth.gwangi-theme.com/members-directory-sidebar-right/

    Can you please help with this?

    Thanks for your help!

    Themosaurus
    Keymaster
    Themosaurus Support
    • 1 Topics
    • 1676 Posts
    @themosaurus

    Hi @prince22,

    The “city”, “country” and “age” field displayed on this demo (https://youth.gwangi-theme.com/members-directory-sidebar-right/) are only available if you use our generated fields.

    As described here (https://doc.themosaurus.com/finishing-buddypress-setup/) you can generate the default fields. Only these are the ones that are displayed on member lists and member profile.

    But you can also display a BP xProfile of your choice by adding the following code snippet to your website:

    if ( ! function_exists( 'gwangi_buddypress_member_country' ) ) :
        /**
         * Print the HTML for the BP xProfile country field.
         *
         * @since 1.0.0
         */
        function gwangi_buddypress_member_country() {
            if ( function_exists( 'xprofile_get_field_data' ) ) :
                $country     = xprofile_get_field_data( 'Country', bp_get_member_user_id() );
                $allowed_html = array(
                    'a' => array(
                        'href' => array(),
                        'rel'  => array(),
                    ),
                );
                if ( ! empty( $country ) ) : ?>
                    <div class="bp-member-xprofile-custom-field bp-member-country"><?php echo wp_kses( $country, $allowed_html ); ?></div>
                    <?php
                endif;
            endif;
        }
    endif;

    Note that your field must have this exact name : “Country”.

    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:

    Adding Custom PHP Without Changing Your Child Theme

    We hope this will solve your issue. ?

    prince
    Participant
    • 12 Topics
    • 19 Posts
    @prince22

    Oh I see! So would it possible to only have the Name and City for each user profile under members directly page with the above code? Or if I generate the default field and modify them?

    Thanks so much again for the clarification.

    Themosaurus
    Keymaster
    Themosaurus Support
    • 1 Topics
    • 1676 Posts
    @themosaurus

    Hi @prince22,

    Yes, you can simply generate the default fields and delete the ones you don’t need to (for example “City”).

    This code is only necessary if you want to display a field that has not been generated by clicking on the button (for example a “hobby” field that you have created by yourself).

    We hope this helps.

    Regards,

    BEN
    Participant
    • 6 Topics
    • 15 Posts
    @benbusiness
    I created a xprofile field called location
    then in code snippet I inserted this code below but it didn't work
    
    if ( ! function_exists( 'gwangi_buddypress_member_country' ) ) :
        /**
         * Print the HTML for the BP xProfile country field.
         *
         * @since 1.0.0
         */
        function gwangi_buddypress_member_country() {
            if ( function_exists( 'xprofile_get_field_data' ) ) :
                $Location     = xprofile_get_field_data( 'Location', bp_get_member_user_id() );
                $allowed_html = array(
                    'a' => array(
                        'href' => array(),
                        'rel'  => array(),
                    ),
                );
                if ( ! empty( $location ) ) : ?>
                    <div class="bp-member-xprofile-custom-field bp-member-country"><?php echo wp_kses( $location, $allowed_html ); ?></div>
                    <?php
                endif;
            endif;
        }
    endif;
    
    I want to display a modified field in xprofile field.
    thanks
    Themosaurus
    Keymaster
    Themosaurus Support
    • 1 Topics
    • 1676 Posts
    @themosaurus

    Hi @benbusiness,

    It seems that there’s a minor misspelling error that leads to the $location not receiving the value from your field as it’s written $Location at the beginning of your code.
    Also gwangi_buddypress_member_country is not displayed in your current version of Gwangi. It’s best if you use gwangi_buddypress_member_location instead.

    Could please retest with the following snippet?

    if ( ! function_exists( 'gwangi_buddypress_member_location' ) ) :
        /**
         * Print the HTML for the location XProfile Field in the BP Member Directory.
         *
         * @since 1.0.0
         */
        function gwangi_buddypress_member_location() {
            if ( function_exists( 'xprofile_get_field_data' ) ) :
                $location     = xprofile_get_field_data( 'Location', bp_get_member_user_id() );
                $allowed_html = array(
                    'a' => array(
                        'href' => array(),
                        'rel'  => array(),
                    ),
                );
                if ( ! empty( $location ) && ! empty( $country ) ) : ?>
                    <div class="bp-member-xprofile-custom-field bp-member-location"><?php echo wp_kses( $location, $allowed_html ); ?></div>
                <?php
                endif;
            endif;
        }
    endif;

    Thank you for keeping us updated.

    Sumit
    Participant
    • 4 Topics
    • 10 Posts
    @sumit784

    Hi,
    I am building a matrimony match website and have created multiple custom profile fields. Out of this I have to show the following fields on header

    1) Age
    2) Current Location
    3) Education
    4) Profile managed by
    5) About Me

    How can I show these fields on the profile header alongwith the existing 2 fields display.

    I have the snippet plugin installed and setup, and tried this snippet but it didnt’ show anything.

    if ( ! function_exists( ‘gwangi_buddypress_member_profileManagedBy’ ) ) :
    /**
    * Print the HTML for the BP xProfile profilemanagedby field.
    *
    * @since 1.0.0
    */
    function gwangi_buddypress_member_profileManagedBy() {
    if ( function_exists( ‘xprofile_get_field_data’ ) ) :
    $profilemanagedby = xprofile_get_field_data( ‘Profile managed by’, bp_get_member_user_id() );
    $allowed_html = array(
    ‘a’ => array(
    ‘href’ => array(),
    ‘rel’ => array(),
    ),
    );
    if (! empty( $profilemanagedby ) ) : ?>
    <div class=”bp-member-xprofile-custom-field bp-member-location”><?php echo wp_kses( $profilemanagedby, $allowed_html ); ?></div>
    <?php
    endif;
    endif;
    }
    endif;

    Themosaurus
    Keymaster
    Themosaurus Support
    • 1 Topics
    • 1676 Posts
    @themosaurus

    Hi @sumit784,

    As mentioned above, you can also display each BP xProfile field of your choice by adding the following code snippet to your website:

    if ( ! function_exists( 'gwangi_custom_buddypress_member_xprofile_custom_fields' ) ) :
        /**
         * Print the HTML for the custom XProfile fields in the BP Member Header.
         *
         * @since 1.0.0
         */
        function gwangi_custom_buddypress_member_xprofile_custom_fields() {
            if ( function_exists( 'xprofile_get_field_data' ) ) :
    			$allowed_html = array(
                    'a' => array(
                        'href' => array(),
                        'rel'  => array(),
                    ),
                );
    
    		    // TODO: Repeat for each field to display.
                $my_field = xprofile_get_field_data( 'My Field', bp_get_member_user_id() );
                if ( ! empty( $my_field ) ) : ?>
                    <div class="bp-member-xprofile-custom-field bp-member-my_field"><?php echo wp_kses( $my_field, $allowed_html ); ?></div>
                <?php
                endif;
    		    // TODO: End repeat.
            endif;
        }
    endif;
    
    add_action( 'gwangi_buddypress_member_xprofile_custom_fields', 'gwangi_custom_buddypress_member_xprofile_custom_fields', 20 );

    Simply replace the $my_field variable by yours (for instance, $age) and replace ‘My Field’ by ‘Age’. Don’t forget to repeat these lines for each field that you wish to display.

    It should do the trick.

    Please also be informed that our support forum will be closed during on December 31st, 2018 and January 1st, 2019.

    Regards,

    Sumit
    Participant
    • 4 Topics
    • 10 Posts
    @sumit784

    Thanks for your quick response. This worked but the Multi checkbox type of fields are not displaying data, instead they just show “Array” text.
    How do I fix this?

    Themosaurus
    Keymaster
    Themosaurus Support
    • 1 Topics
    • 1676 Posts
    @themosaurus

    Hi @sumit784,

    For multi checkbox fields, in the previous snippet you just need to change this line:

    $my_field = xprofile_get_field_data( 'My Field', bp_get_member_user_id() );

    Like this:

    $my_field = xprofile_get_field_data( 'My Field', bp_get_member_user_id(), 'comma' );

    Don’t forget to replace $my_field and ‘My Field’ by the field of your choice.

    Regards,

    Malas Reda
    Participant
    • 13 Topics
    • 28 Posts
    @malasreda

    Hello,

    I am using this code snippet to show on the member directory some fields. Everything is working fine but the field “vos fantasmes” won’t diplay. It shows array instead. The field in question is a check box ! how can i make it work ?

    if ( ! function_exists( 'gwangi_custom_buddypress_member_xprofile_custom_fields' ) ) :
        /**
         * Print the HTML for the custom XProfile fields in the BP Member Header.
         *
         * @since 1.0.0
         */
        function gwangi_custom_buddypress_member_xprofile_custom_fields() {
            if ( function_exists( 'xprofile_get_field_data' ) ) :
                $allowed_html = array(
                    'a' => array(
                        'href' => array(),
                        'rel'  => array(),
                    ),
                );
         // TODO: Repeat for each field to display.
             
    
                $êtes_vous = xprofile_get_field_data( 'Êtes-vous', bp_get_member_user_id() );
                if ( ! empty( $êtes_vous ) ) : ?>
                    <div class="bp-member-xprofile-custom-field bp-member-my_field"><?php echo wp_kses( $êtes_vous, $allowed_html ); ?></div>
                <?php
                endif;
    		
    		  $vos_fantasmes = xprofile_get_field_data( 'Vos fantasmes', bp_get_member_user_id() );
                if ( ! empty( $vos_fantasmes ) ) : ?>
                    <div class="bp-member-xprofile-custom-field bp-member-my_field"><?php echo wp_kses( $vos_fantasmes, $allowed_html ); ?></div>
                <?php
                endif;
    		
           
    
                // TODO: End repeat.
            endif;
        }
    endif;
    
    add_action( 'gwangi_buddypress_member_xprofile_custom_fields', 'gwangi_custom_buddypress_member_xprofile_custom_fields', 20 );
    Themosaurus
    Keymaster
    Themosaurus Support
    • 1 Topics
    • 1676 Posts
    @themosaurus

    Hi @malasreda,

    To fix this, you just need to do the same as described in my previous post in this topic.

    In your case that means you have to replace that line:

    $vos_fantasmes = xprofile_get_field_data( 'Vos fantasmes', bp_get_member_user_id() );

    By this one instead:

    $vos_fantasmes = xprofile_get_field_data( 'Vos fantasmes', bp_get_member_user_id(), 'comma' );

    Hope this fixes your issue.

    Best regards,

Roboraptor 🦖
Themosaurus Topic Closer

Hi there,

This topic has been inactive for a while now so we will be closing it to keep the forum tidy. Don't hesitate to create a new topic if you still need help and we'll be glad to help you!

Best regards,
The Themosaurus team.

Viewing 14 posts - 1 through 14 (of 14 total)

The topic ‘Display City on User Profile’ is closed to new replies.

Troubleshooting Demo Imports

You're trying to setup your theme but you're experiencing errors when importing the demo content? Or you've just followed the setup guide but your website doesn't look exactly like our demo? These are common issues for which you can find easy and quick fixes.

Happy With our Support So Far?

Feel free to review our theme on Themeforest! It helps us making our products more known to new potential customers, which allow us more time to improve the quality and develop new features. #SharingIsCaring ❤️

Discover MatchPress

Skip • Like • Super-Like

Add powerful matching features like Member likes, skips, super likes, conditional private messaging and much more.

Setup Your Cera-powered Community Website and Turn it into an iOS and Android App

15% discount for Cera users

To unleash the full power of the Cera theme, we have partnered with the Zipline team. Your community website can now be fully setup and turned into your very own custom app for iOS and Android.

Whether you're new to Cera and already got your site up and running, Zipline got you covered. And we got you an incredible discount.

Holiday, Weather & Festive effects
to pimp your WordPress Site