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 same fields as member directory on member swap cards

This topic is resolved
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • Malas Reda
    Participant
    • 13 Topics
    • 28 Posts
    @malasreda

    Hey,

    I have found another issue regarding the members swap page, the profile card does not show the same items as on the search results like matching hearts on the right bottom corner and other fields.

    I have used the snippet plugin to show some fields on the members page but does not appear on the swap members page. How can i make them appear as well as the matchmaking button ?

    Best regards,

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

    Hi @malasreda,

    1. For the matching button on the member swap, good timing because we have just release a new version of Gwangi (v 1.1.9) that adds the matching button in the member swap view!

    To update your theme, you can download and install the Envato Market plugin (https://envato.com/market-plugin/) on your WordPress site.

    Once the plugin is installed and activated, go to “Envato Market” in your admin menu and follow the instructions under “Activate Envato API Connection”.

    When this is done, you will see your purchased themes under the “Themes” tab and you should be able to update your Gwangi theme from there by clicking the “Update available” button.

    Also, don’t forget to update your child theme if you are using one, and update all of our Grimlock plugins to their latest versions.

    2. For the member fields, can you send us the code snippet that you used to display your member fields in the member directory? That way we can take a look and try to find why they are not displayed on the member swap page.

    Regards

    Malas Reda
    Participant
    • 13 Topics
    • 28 Posts
    @malasreda

    hello,

    By updating the theme, the fileds also appeared in the swap section ! Wich is great !

    But when i add a codeWhen i add a code snippet to display the member age on the member directory, it shows the date format d/m/year.

    How can i show only the age not the date ?

    Thank you

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

    Hi @malasreda,

    This is great news 🙂

    Right now you are directly displaying the birthdate instead of the age. Here is a code snippet that should display the age:

    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( 'Birthdate' );
    
    			if ( ! empty( $birthdate_field_id ) ) :
    				$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;
    
    				$allowed_html = array(
    					'a' => array(
    						'href' => array(),
    						'rel'  => array(),
    					),
    				);
    				if ( ! empty( $age ) ) : ?>
    					<div class="bp-member-xprofile-custom-field bp-member-birthdate"><?php echo wp_kses( $age, $allowed_html ); ?></div>
    				<?php
    				endif;
    			endif;
    		endif;
    	}
    endif;

    Don’t forget to change 'Birthdate' with your own field name. If you replace your snippet by that one, it should do the trick.

    Regards,

    Malas Reda
    Participant
    • 13 Topics
    • 28 Posts
    @malasreda

    Thank you it works.

    On the profile page, profile informations how can i show the age rather than the date ?

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

    Hi @malasreda,

    Glad we could help 🙂

    Here is another code snippet that should do the trick:

    add_filter( 'bp_get_the_profile_field_name', 'gwangi_change_birthdate_field_name' );
    function gwangi_change_birthdate_field_name( $field_name ) {
    
    	if ( $field_name === 'Birthdate' && bp_is_user_profile() && ! bp_is_user_profile_edit() ) {
    		return 'Age';
    	}
    
    	return $field_name;
    }
    
    add_filter( 'bp_get_the_profile_field_value', 'gwangi_change_birthdate_field_value', 10, 3 );
    function gwangi_change_birthdate_field_value( $value, $type, $id ) {
    
    	$field = xprofile_get_field( $id );
    
    	if ( ! empty( $field ) && $field->name === 'Birthdate' ) :
    		$birthdate                = $value;
    		$birthdate_field_settings = BP_XProfile_Field_Type_Datebox::get_field_settings( $id );
    
    		if ( 'elapsed' !== $birthdate_field_settings['date_format'] ) :
    			$birthdate_datetime = DateTime::createFromFormat( $birthdate_field_settings['date_format'], $birthdate );
    			if ( ! empty( $birthdate_datetime ) ) :
    				$value = $birthdate_datetime->diff( new DateTime( 'now' ) )->y;
    			endif;
    		endif;
    	endif;
    
    	return $value;
    }

    Once again, please don’t forget to change Birthdate by your own field name and Age by the name you want to display instead of Birthdate.

    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 6 posts - 1 through 6 (of 6 total)

The topic ‘Display same fields as member directory on member swap cards’ 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 or Gwangi powered Community Website and Turn it into an iOS and Android App

15% discount for Cera users

To unleash the full power of your Cera or Gwangi 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've newly acquired the theme or 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