Modifying The Member List
-
My member list appears there:
http://www.1a-spielwiese.de/die-teams/
I would like to substitute the lines “Derzeit nicht aktiv” (Currently not active) or “aktiv gerade jetzt” (active right now) through some information from the extended profiles, e.g. “age” or “Town”.
Is there any easy solution for that?
-
Yes, by creating a custom function.
Add custom filters to loops and enjoy them within your plugin
https://codex.buddypress.org/plugindev/using-bp_parse_args-to-filter-buddypress-template-loops/How to
https://wordpress.org/support/topic/display-profile-fields-in-the-members-directory-all-members
(2nd topic gives a technique you can use)Thank you very much!
Regarding the last two links: Both mention the members-loop.php. The second link says more detailed: “For example in your theme, search /members/members-loop.php file.”
Unfortunately I can’t find neither the mentioned file nor any members folder even.
Unfortunately I can’t find neither the mentioned file nor any members folder even.
Oups ! Was ist denn hier los ? Hast Du überhaupt BuddyPress instaliert ? :d
wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/members/members-loop.php
To modify this file, you make a copy of it and put it into your child-theme
/your-child-theme/buddypress/members/members-loop.phpIch glaube echt dass bevor du alles umbaust, das du heftig über BP lesen (und lernen) solltest !
“Ich glaube echt dass bevor du alles umbaust, das du heftig über BP lesen (und lernen) solltest!”
Gibt es ein aktuelles umfassendes deutsches Handbuch für BuddyPress? – Ich hatte gestern beim Suchen keines gefunden.
“Hast Du überhaupt BuddyPress instaliert ? :d”
I found the file at the mentioned place. I don’t know, why I didn’t find it before.
Sometimes after a beer or two, things goes different ! 😀
Gibt es ein aktuelles umfassendes deutsches Handbuch für BuddyPress?
Keine ahnung ! Hast du schon hier gefragt ? http://forum.wpde.org/buddypress/
Vielleicht auch hier: https://plus.google.com/communities/109252196176086284868
oder bei David: http://deckerweb.de/@ https://buddypress.org/support/topic/modifying-the-member-list/#post-187019:
wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/members/members-loop.php
To modify this file, you make a copy of it and put it into your child-theme
/your-child-theme/buddypress/members/members-loop.phpI did it, and inserted behind:
<?php /*** * If you want to show specific profile fields here you can, * but it'll add an extra query for each member in the loop * (only one regardless of the number of fields you show): * * bp_member_profile_data( 'field=the field name' ); */ ?>
the following code:
<?php bp_member_profile_data( 'field=Geschlecht' ); ?> <br> <?php bp_member_profile_data( 'field=Teamgründung bzw. Geburtsjahr' ); ?> <br> <?php bp_member_profile_data( 'field=Bundesland, Kanton oder Wahlkreis' ); ?>
The first and the third fields are displayed; the second not. – Why and how can I change it?
1. I renamed the second field from ‘Teamgründung bzw. Geburtsjahr’ into ‘year’ – and it works.
2. With the field ‘Bezirk oder Statutarstadt; CH: Bezirk o.ä.; D: LANDKREIS oder KREISFREIE STADT; Li: Gemeinde’, again, it does not work. – Therefore I guess, the problem are blank, points etc. – Is true? Is there a any way to resolve the problem?
3. Is there any way to get displayed the age at any current moment (instead of the year of brith or team fundation, which is inserted into profile fields)?
I get now managed to place the information from the profile fields Geschlecht, Jahr, Bundesland/Kanton in one line (instead below each other):
http://1a-spielwiese.de/teams/
The code is now:
<table-member border="0"> <tr> <td>| Geschlecht: <?php bp_member_profile_data( 'field=Geschlecht' ); ?> | </td> <td>Geburts-/Gründungsjahr: <strong><?php bp_member_profile_data( 'field=Jahr' ); ?></strong> | </td> <td>Bundesland/Kanton: <?php bp_member_profile_data( 'field=Bundesland, Kanton oder Wahlkreis' ); ?> / </td> <td><?php bp_member_profile_data( 'field=A:Bezirk oder Statutarstadt; CH: Bezirk o.ä.; D: LANDKREIS oder KREISFREIE STADT; Li: Gemeinde' ); ?> |</td> </tr> </table-member>
Nevertheless
- the problem regarding the field ‘A:Bezirk oder Statutarstadt; CH: Bezirk o.ä.; D: LANDKREIS oder KREISFREIE STADT; Li: Gemeinde’ persits: That information should appear at the ende of the line, betwen ‘/’ and ‘|’.
- and as well I would still like to know, whether it is possible to transform the ‘year of birth’-information into an ‘age’-information.
Ask the age instead of date of birth !
Your age: [ ] text-filed numeric type
else you have to code it yourself. Some answers here.
Ask the age instead of date of birth !
That would imply that the users would have to update their profiles each years or would have every year the same age, isn’t it? –
Therefore I will try the second way.
I tried the following:
1st:
I created a new profile ‘Tag’ (description: ‘der Geburt oder Teamgründung’).
2nd:
Consequently I substitute within the first code of @sbrajesh
$dob_field_name
by$tag
.Besides I reduce
$format="%y Years, %m Month(s), %d days"
to$format="%y"
Therefore the code, which I inserted into my reddle-child/functions.php, was:
/** * Get Age from BuddyPress date of Birth * <a href='https://buddypress.org/community/members/param/' rel='nofollow'>@param</a> string $dob_field_name :name of the DOB field in xprofile, like Dob or Date of Birth * <a href='https://buddypress.org/community/members/param/' rel='nofollow'>@param</a> int $user_id : the user for which you want to retrieve the age * <a href='https://buddypress.org/community/members/param/' rel='nofollow'>@param</a> string $format: the way you want to print the difference, look t for the acceptable agrs * @return string :the formatted age in year/month */ function bpdev_get_age_from_dob($tag,$user_id=false,$format="%y"){ if(!$user_id) $user_id=bp_displayed_user_id (); $dob_time=xprofile_get_field_data($tag, $user_id);//get the datetime as myswl datetime $dob=new DateTime($dob_time);//create a DateTime Object from that $current_date_time=new DateTime();//current date time object //calculate difference $diff= $current_date_time->diff($dob);//returns DateInterval object //format and return return $diff->format($format); }
3rd:
I substitute within the second code of @sbrajesh
"DOB Field Name"
bytag
and I deleted"Age".
.Therefore I inserted into my reddle-child/buddypress/members/members-loop-.php:
<td>Alter: <?php echo bpdev_get_age_from_dob(tag); ?> | </td>
Result: I get for all user the age ‘0’ (zero) displayed.
4th:
For test purpose I substituted
tag
bytag,bp_loggedin_user_id()
.Then I get displayed the correct age of that user, which is currently logged in with my computer – but as age of all users.
5th:
Conclusion:
echo bpdev_get_age_from_dob(tag);
(cfr. section 3rd) is not the correct code for my purpose. – What have I to change?I tried as well
tag,bp_displayed_user_id
andtag,bp_members
– both without and with()
at the end (- instead of onlytag
). – All four variants did not work.—-
Additional remark:
That, what is described within section 4th works not, when the current user his-/herself has set his/her date of birth. It worked only, when the date of birth was set by the superadmin and then another user logged in.
The basic issue is resolved.
Regarding the two persting problems I have started more specific topics:
https://buddypress.org/support/topic/age-for-each-user-instead-of-age-for-logged-in-user/
and
https://buddypress.org/support/topic/addressing-profile-fields-with-complex-names/
Therefore, for my point of view, this topic could be closed.
- The topic ‘Modifying The Member List’ is closed to new replies.