How to get the profile field name and its value in the members loop?
-
I need the name of the field which is “Location” as well as its value which is “AMerica” I been able to get the value using
<?php bp_member_profile_data('field=Location'); ?>
but it only spits out America which is just the value. I also need the field name which is “Location” so it will add “Location: America” in the members loop. Any advice?
-
Location: <?php bp_member_profile_data('field=Location'); ?>
@modemlooper Isn’t there a way to pull “Location” from the database? I am trying to get location dynamically. The admin enters that name in the dashboard and the users enter those values so there should be a way to pull them both in right?
@whitewolf1988
I am about 85% done with a plugin that will do this and It will be a freebie so hold your horses! Until then this is a current screen shot of what It will produce on the front end dependent on how the admin sets it in the dashboard:
I am working on making those xprofile items that are not filled out to not display unless they are. When I get it finished everyone gets a cool freebie! Patience!@bphelp Why would you do this?
@whitewolf1988 @hnla
On second thought after resting last night, I may take some time to decide whether I should release this plugin. I was tired, excited and had been up half way through the night working on this plugin when I replied, and maybe I did not think about how it would affect others in a negative way. So my apologies, but like I said I have not come to a decision yet! I will take a few days to decide and then make a decision when I can make a better judgement call.@hnla
You asked “Why?” the reason is simple. I don’t have $15.00 to cough up for a plugin myself so I did it the old fashioned way, I built it myself! I suppose in some unselfish way I thought since I already built it, I would share it for those like myself that can’t afford it. I have several plugins out and it isn’t like they are revolutionary and neither would this one be. Maybe not being able to afford it is to my advantage of learning, and giving back to the community, and the community gains from my misfortunes! I understand you and shane are partners so I can see how you would take a personal interest in this, but the fact of the matter is I didn’t intend on stepping on anyone’s toes, and I don’t know either one of you personally either, but I needed this functionality and I could not afford to pay for it, and since I built it I figured I may as well share it with others that may not be able to afford it. If you can give me some ethical reasons why I should not share the plugin then I will take them into consideration before I make a decision to release it because I really do not intend to harm anyone or their income.@bp-help
I don’t think you have to explain someone why you do or don’t do things. As Buddypress is Open Source and as long as people do things for free, I’ll appreciate their work. I don’t think that the guy who developed a paid version of the plugin you do for free has to starve or die because of your work – maybe he has to think about some more advanced functions – so, I would be glad to get a free version of your plugin!Greetings,
noizeburgerand there you have it!
Now we return the thread to the OP as there is a question remaining unanswered.
@whitewolf1988
Here is one way you could add xprofile fields name as well as the value to the members directory! Just remember to replace “Field-Name with the names of your fields in the 5 variables in my code. Also remember it is case sensitive. If you notice the pattern of 5 in my code you can easily see how to add more fields if you need them. Place this code in bp-custom.php:<?php add_action('bp_directory_members_item', 'bphelp_dpioml'); function bphelp_dpioml(){ $bphelp_my_profile_field_1='Field-Name'; $bphelp_my_profile_field_2='Field-Name'; $bphelp_my_profile_field_3='Field-Name'; $bphelp_my_profile_field_4='Field-Name'; $bphelp_my_profile_field_5='Field-Name'; if( is_user_logged_in() && bp_is_members_component() ) { ?> <div class="bph_xprofile_fields" style=" margin-left: 25%;"> <?php echo $bphelp_my_profile_field_1 ?>: <?php echo bp_member_profile_data( 'field='.$bphelp_my_profile_field_1 ); ?><br /> <?php echo $bphelp_my_profile_field_2 ?>: <?php echo bp_member_profile_data( 'field='.$bphelp_my_profile_field_2 ); ?><br /> <?php echo $bphelp_my_profile_field_3 ?>: <?php echo bp_member_profile_data( 'field='.$bphelp_my_profile_field_3 ); ?><br /> <?php echo $bphelp_my_profile_field_4 ?>: <?php echo bp_member_profile_data( 'field='.$bphelp_my_profile_field_4 ); ?><br /> <?php echo $bphelp_my_profile_field_5 ?>: <?php echo bp_member_profile_data( 'field='.$bphelp_my_profile_field_5 ); ?><br /> </div><?php } } ?>
@bphelp This works good! I cant wait till you release the plugin. Pay no mind to the ones discouraging you. They are just upset because something to loose is at stake. @noizeburger and myself would welcome this plugin and I dont care if it upsets anyone. You have to ask yourself what did they ever do for you? I seriously doubt they did a darn thing! So I hope you consider adding this plugin soon.
@whitewolf1988 @noizeburger
Thank you both, and I suppose you are both correct. I will release the plugin when I get it done. If its for the greater good then I will not let anyone that would oppose this deter my efforts!@whitewolf1988
Your attitude on this matter is a little off, people are not upset because they stand to loose something it’s not about that whatsoever. You should care if you upset people! 🙂 why upset people just to satisfy your requirements?and this statement beggars belief:
You have to ask yourself what did they ever do for you? I seriously doubt they did a darn thing
Myself and many others involved in buddypress give a huge amount of our time to this project so that you can have everything for free, if in doubt about this just check my trac ticket submission, comments, and patches to core files and I’m one of the minor players!And on that note can we have less of the jibes please, not everything is for free and the developers that actually keep these OS projects running have a right to try and get some paultry return on the considerable time they give to these projects, there are principles here but I’m not about to get into discussions about the nature and drawbacks of GPL licences.
Closing this thread now.
- The topic ‘How to get the profile field name and its value in the members loop?’ is closed to new replies.