Search Results for 'display user role on profile page'
-
AuthorSearch Results
-
October 29, 2009 at 12:02 am #55377
In reply to: Filter members by custom fields
buzz2050ParticipantWell, I would be happy to share the solution, but I don’t really think my way is all that elegant, there’s got to be a better way and I’m waiting for someone to suggest it to me.
Meanwhile, I am still using the old 2-theme model. I made some customizations in my bpmember theme to achieve this and put in some code in plugins/bp-custom.php as well.
Firstly, we have a custom profile field called ‘Role’. And we wanted to have separate Role-tabs (as you can see on our site) to list all members for THAT role.
To achieve this, I completely changed the bpmember/directories/members/index.php code and put in my ‘Role’ tab-structure there. Then, instead of making the members index file call the members-loop, I wrote a modified version of the members-loop, made it as a function and put it in my bp-custom.php. Now I make a call to this function (which is basically the members-loop) from my bpmember/directories/members/index.php page.
To give you an eg of how we display all companies under the Company tab:
In my bpmember/directories/members/index.php, under the code section for ‘Company’ tab I make a call like:
display_members_by_role(‘Company’);
In my bp-custom.php, I have written a function display_members_by_role($role) which is nothing but a slightly modified version of the members-loop.
Here, in the ‘while’ for members-loop, I check for the Role field for that user-id. For this eg, if the Role is ‘Company’, print that member in the company-listing, else not.
This is the code I have put in the members-loop which checks the custom profile field (which is this case is ‘Role’) and it’s value for that user-id:
...
...
<?php while ( bp_site_members() ) : bp_the_site_member(); ?>
<?php
global $site_members_template ;
$arr = BP_XProfile_ProfileData::get_value_byfieldname(array('Role'), $site_members_template->member->id) ;
if( $arr['Role'] == $role) //$role is the role value received by the function, in this eg - Company
{
//do whatever
}
<?php endwhile; ?>
....
....Same logic is used for all other roles.
BTW, get_value_byfieldname() can return values for multiple fields too. In case you want to retrieve values of more than one profile fields, its easily possible. Say I want the ‘City’ custom field value too, then I would pass something like –
$arr = BP_XProfile_ProfileData::get_value_byfieldname(array(‘Role’,’City’)
and access the ‘City’ value using $arr[‘City’]
This function is pretty handy.
While I am able to print the members belonging to that corresponding role using this logic, what I can’t get into place is the pagination part. The pagination still takes into account ‘All’ members since the members-loop technically does retrieve all members.
All I have done is put a condition in order to just get the members for that role displayed. I was wondering if I should put in a separate pagination module, or if there is any other way of achieving this whole thing.
-Sib
July 15, 2009 at 7:22 am #49346In reply to: New Groupblog Plugin
MariusoomsParticipantGood idea r-a-y! It is summer vacation now, but I will definitely include some as our users start building their profile and groups with this plugin. These are some upcoming feautures:
* Construct the group_id, this allows us to switch blogs in the group and pull in the relevant information. (done)
* Construct the reverse blog_id, this allows us to have group based loops in the blog to display members, profile, activity etc based on the group id. (done)
* Allow blog registration at group sign up, much like how you can create a blog at site registration.
* Add members silently to the blog when they become group members.
* Different role caps depending on role within the group. By default members are authors, mods are editors and admins are admins.
* Allow the admin set role caps on group roles, e.g. the group admin only want its members to be subscribers. Or editors for a wiki type solution.
* Have an option to disable silent adding of members in case the group admin only wants (or needs) the group blog be accessible by him (or her).
* Create more templates. One we have now is a simple template that creates a menu from the page titles, which allows the group to behave like a cms.
We will also offer some blog templates to help make the blog look transparent to the information you display within the group so its transition from group to blog nad vice versa is seemless.
Thanks for your interests already.
-
AuthorSearch Results