Find Answers and Get Support › Forums › Gwangi – PRO Multi-Purpose Membership, Social Network & BuddyPress Community Theme › Popular Features › Member Swap › Display same fields as member directory on member swap cards
- This topic has 5 replies, 2 voices, and was last updated 6 years, 1 month ago by
Themosaurus.
-
AuthorPosts
-
Malas RedaParticipant@malasreda
- 13 Topics
- 28 Posts
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,
January 28, 2019 at 15:04 #4855@themosaurus- 1 Topics
- 1675 Posts
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
January 28, 2019 at 16:47 #4865Malas RedaParticipant@malasreda- 13 Topics
- 28 Posts
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
January 29, 2019 at 00:07 #4881@themosaurus- 1 Topics
- 1675 Posts
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,
January 29, 2019 at 11:10 #4899Malas RedaParticipant@malasreda- 13 Topics
- 28 Posts
Thank you it works.
On the profile page, profile informations how can i show the age rather than the date ?
January 29, 2019 at 20:26 #4916@themosaurus- 1 Topics
- 1675 Posts
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 andAge
by the name you want to display instead of Birthdate.Regards,
January 30, 2019 at 12:48 #4936 -
AuthorPosts
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.
The topic ‘Display same fields as member directory on member swap cards’ is closed to new replies.