Search Results for 'display user role on profile page'
-
Search Results
-
Hello,
I´m searched endless hours and didn´t found anything to solve my problem. Hope a lot that you can help me.
I want to give the admins of every group the possibility to enter a value related to a specific user in his group.
Background is that I want to create a gaming clan network and I want to organize the clans as groups. So the admin should be able to set a custom “role” (not with any permissions or anything like that, only a value related to the specific user) for each user.I checked dozens of plugins to find one where a group admin is able to set something for a group member to customize it because I´m not much into php. But I couldn´t find anything useful.
Next idea was to hook into the “Promote to”-function, so I can use the already existing structure and adding “only” some custom statuses without any further permissions. But I can´t get it to work, if I´m changing anything related to this in my functions.php, or even direct in the BuddyPress/src/bp-groups/bp-groups-functions.php, the website is broken. :´-(
The perfect solution would be a possibility for every group admin to enter a custom value related to a specific user of his group in the members area in group management.
In example
User Set rank
Testuser [textfield]
Testuser 2 [textfield]But also every other working solution would be also perfect.
I want to display the rank then under the username in the group members page and on the members profile under groups. That shouldn´t be a problem. I have only no idea how to give the admin of a group the possibility to save a value related to an user of his group. The value must be saved in the group because the user should be able to choose more than one group, so it doesn´t make much sense to save it in the user database I think.
Any idea how I can get this to work? I was really surprised and dissapointed that I couldn´t find anything like this.
Thanks a ton already.
Topic: CIMY User Fields
Hi,
I am not using buddy press registration pages.
So a lot of my field data is not showing on user profile.
I would like to transfer the cimy extra user fields over to buddy press but do not know where to begin.
If possible I want to display these fields on the user profiles in the table.
I have added the following code to boss-child/buddypress/members/single/member-header.php
$user = wp_get_current_user(); // is there someone logged? if ($user->ID) { $value = cimy_uef_sanitize_content(get_cimyFieldValue($user->ID, 'ROLE')); echo 'description_here'; } do_action( 'bp_profile_header_meta' );
It did not work. If anyone could help out, it would be appreciated.
Thanks
Hi all, i’m trying to set different BP profile landing page for different user roles.
Here’s what i’ve tried;
function bp_default_tab (){ global $bp; if ( bp_is_user() ) { $wcv_profile_info = get_userdata( bp_displayed_user_id() ); if ( $wcv_profile_info->roles[0] == "vendor" ){ define('BP_DEFAULT_COMPONENT', 'my-store' ); } else { define('BP_DEFAULT_COMPONENT', 'following' ); } } } add_action( 'bp_loaded', 'bp_default_tab' );
With this code, landing profile change only set to the ‘else’ (following in regards to code above). Couldn’t manage to change for the ‘vendor’ user role. Anybody have any idea how?
Thanks in advance!Hi, I’m sorry if the question is quite noobish; its because I am. I’m trying to use bp_displayed_user_id() for a code I’m writing. It’s fine when use inside a function, but when using outside of function, i got error “Fatal error: Call to undefined function bp_displayed_user_id()…”. Can anybody explain to me why so?
to paint a better picture, i’m trying to set different BP profile landing page for different user roles. Here’s the code that i put in bp-custom.php
global $bp; $displayed_user = bp_displayed_user_id(); $member_id = get_userdata( $displayed_user ); if ( $member_id->roles[0] == $role ){ $default_landing = define('BP_DEFAULT_COMPONENT', 'my-store' ); } else { $default_landing = define('BP_DEFAULT_COMPONENT', 'following' ); }
It’s a bit out of topic, but if I use the above code in a function, can anybody point me to what hook/action to use along the function to be able to fire up the above code?
Hope I’m making some sort of sense here.
Hi,
My issue – Member page not displaying and members
I have confirmed signup by seeing the user in the users area. Role is subscriber.
BP created a page called Members. I have assigned the Members as the BP Members page in Settings>Buddypress>Pages.
When I click on this page from http://gamma.rabbitholeconsulting.com/, it is empty.
Any ideas why?
Thanks for your help!
System info:
WP 4.4.2
PHP 5.4.2
Default theme 2016 to avoid conflicts while setup/learning
Buddypress 2.5
BP Profile Search activated
Membership Pro 1.2.7.4I need to Hide a div based on authors pmpro role level or wp role level?
I have 2 types of account sellers and buyers
on the buddypress members page of the seller I have added a button to take them to the sellers storefrontI added this to the members-header inside my themes buddypress
<div id=”item-header-avatar2″ class=”btn btn-default” >
“> Buy Training Packages
</div>
simple button as the storefront url is always the same as the users name
however well this also adds the button to the buyers pages and they dont have a storefront 🙂
so I need a way to filter the button according to the authors/buddypress member page being viewed if the author is a buyer or pmppro level 1 WProle= subscriber then this div will not be displayed in their buddypress page
I foud this snippet for pmpro
Check for a specific user_id (i.e. not the current user).<?php
$user_id = 1; //some other user
if(pmpro_hasMembershipLevel(1, $user_id))
{
?>
//Place your HTML or PHP code here if the user is in the required membership level
…
<?php
}
?>soo…..
if(pmpro_hasMembershipLevel(1, $user_id))
should be ????
if(pmpro_hasMembershipLevel(1,bp_displayed_user_id()))
as this states it is a free pmpro level 1 member aka subscriber,buyer and the user id is drawn from the users profile page being viewed right?
so if the above pmpro function is correct how do i apply it to hide the div sorry I am new to this stuff and lack the basic php fundamentals i guess 🙂
so if anyone can help and take my div code and show me how to hide it by the authors role either wp role of pmpro role just need to hide the store front button if the user doesnt have a store . thanks
Hi, I’m creating a page where I want to list all members and then let the users filter them by for example location by checking checkboxes.
I created a quick mockup in photoshop of what I’m creating.
I’m working in the members-loop.php and my code works backend, my problem is to connect to front-end. Firstly I have an empty array of locations I want to filter by $locationValg. If I manually add a location, let’s say Oslo (The capital of Norway) to the Array, the loop spits out users wich have set the location to Oslo. So the code itself works. Prior to starting, I heard that you could connect front-end to the back-end by using Ajax and jQuery.
After hours of trying and googling I’m not able to figure this out. Right now I’m just debugging with a button to echo out some words from a PHP function to see if it works, but ultimately I want the users to check the box “Oslo”, and The script add Oslo to my $locationValg array and rerun the script.This is my members-loop (a bit messy right now after hours of testing). The code is semi-Norwegian and English, so sorry for the confusion.
Any advice for a PHP-Wordpress-Buddypress starter? 🙂
<?php /** * BuddyPress - Members Loop * * Querystring is set via AJAX in _inc/ajax.php - bp_legacy_theme_object_filter() * * @package BuddyPress * @subpackage bp-legacy */ ?> <?php $locationValg = array(); setVerdier(); if(isset($_POST['action']) && !empty($_POST['action'])) { $action = $_POST['action']; switch($action) { case 'test' : setEcho();break; case 'post' : setEcho();break; // ...etc... } setVerdier(); } function setEcho(){ echo"trykket på knapp"; } function setVerdier(){ global $locationValg; /*$locationValg[] = "Oslo"; $locationValg[] = "Telemark"; $locationValg[] = "sd"; echo $locationValg[1]; */ lagListe(); } /** * Fires before the display of the members loop. * * @since BuddyPress (1.2.0) */ function lagListe(){ global $locationValg; do_action( 'bp_before_members_loop' ); ?> <?php if ( bp_get_current_member_type() ) : ?> <p class="current-member-type"><?php //bp_current_member_type_message() ?></p> <?php endif; ?> <?php if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : ?> <div id="pag-top" class="pagination"> <div class="pag-count" id="member-dir-count-top"> <?php //bp_members_pagination_count(); ?> </div> <input type="submit" value="Last side" id="lastsideBtn"/> <div id="sorteringsvalg"> <h2> Sorter artister</h2> <ul> <label for="oslo">Oslo</label> <li><input type="checkbox" id="oslo" name="Oslo" value="Oslo"/></li> </ul> </div> <div class="pagination-links" id="member-dir-pag-top"> <?php //bp_members_pagination_links(); ?> </div> </div> <?php /** * Fires before the display of the members list. * * @since BuddyPress (1.1.0) */ do_action( 'bp_before_directory_members_list' ); ?> <ul id="members-list" class="item-list"> <?php $numbersOfLocationsChecked = count($locationValg); while ( bp_members() ) : bp_the_member(); ?> <?php //$brukerType = bp_member_profile_data('field=Type');; // echo 'brukertype:' . $brukerType; $user = new WP_User( bp_get_member_user_id() ); $userLocation = bp_get_member_profile_data('field=Område'); //dele opp basert på komma $ordSomSkalDeles = $userLocation; $oppdeltOrd = explode(',', $ordSomSkalDeles); $antallOppdelteOrd = count($oppdeltOrd); //echo("Lengde" . $numbersOfLocationsChecked); //echo "Arrayinnhold: " . $locationValg[1]; //echo "Lokasjon fra profil: " . $userLocation; //This will check if the users hasent cheked anything, and prints all data if($numbersOfLocationsChecked == 0){ //print alt //I know, this is not good coding with the same lines copy pasted if ( $user->roles[0] == 'subscriber' ){ ?> <li <?php bp_member_class(); ?>> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar('type=full&width=100%&height=180'); ?></a> </div> <div class="item"> <div class="item-title"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a> </div> <div class="item-title"> <a href="<?php bp_member_permalink(); ?>"><?php bp_get_member_type($user_id); ?></a> </div> <div class="musikertype"> <span><?php bp_member_profile_data('field=Type'); ?></span> </div> <div class="musikerlokasjon"> <span><?php bp_member_profile_data('field=Område'); ?></span> </div> <div class="musikerprissjikte"> <span><?php bp_member_profile_data('field=Prissjikte'); ?></span> </div> <?php /** * Fires inside the display of a directory member item. * * @since BuddyPress (1.1.0) */ do_action( 'bp_directory_members_item' ); ?> <?php //bp_member_profile_data('field=Type'); /*** * 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' ); */ ?> </div> <div class="action"> <?php /** * Fires inside the members action HTML markup to display actions. * * @since BuddyPress (1.1.0) */ do_action( 'bp_directory_members_actions' ); ?> </div> <div class="clear"></div> </li> <?php } //Ferdig med å printe ut alt }else{ //print kun field med riktig område for($i = 0;$i< $numbersOfLocationsChecked;$i++){ for($x = 0;$x < $antallOppdelteOrd;$x++){ //echo("oppdelte ord før løkke " . $oppdeltOrd[0] ); $omrade = str_replace(' ', '', $oppdeltOrd[$x]); //echo("oppdelte ord før løkke område " . $omrade . " SLUTT"); $omradeFraValgt = str_replace(' ', '', $locationValg[$i]); $printet = false; if($omrade===$omradeFraValgt){ // echo("oppdelte ord fra løkke " . $oppdeltOrd[$x] ); //printing only data where the lcoation is selected if ( $user->roles[0] == 'subscriber' ){ ?> <li <?php bp_member_class(); ?>> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar('type=full&width=100%&height=180'); ?></a> </div> <div class="item"> <div class="item-title"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a> </div> <div class="item-title"> <a href="<?php bp_member_permalink(); ?>"><?php bp_get_member_type($user_id); ?></a> </div> <div class="musikertype"> <span><?php bp_member_profile_data('field=Type'); ?></span> </div> <div class="musikerlokasjon"> <span><?php bp_member_profile_data('field=Område'); ?></span> </div> <div class="musikerprissjikte"> <span><?php bp_member_profile_data('field=Prissjikte'); ?></span> </div> <?php /** * Fires inside the display of a directory member item. * * @since BuddyPress (1.1.0) */ do_action( 'bp_directory_members_item' ); ?> <?php //bp_member_profile_data('field=Type'); /*** * 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' ); */ ?> </div> <div class="action"> <?php /** * Fires inside the members action HTML markup to display actions. * * @since BuddyPress (1.1.0) */ do_action( 'bp_directory_members_actions' ); ?> </div> <div class="clear"></div> </li> <?php } $printet = true; //slutt på løkka som skal sjekke profil ord } else{ //echo $omrade . " og " . $omradeFraValgt . " er ulike"; } //Stopper løkka dersom den printes ut siden det kan være flere med samme lokasjon if($printet == true){ break; } } } } endwhile; ?> </ul> <?php /** * Fires after the display of the members list. * * @since BuddyPress (1.1.0) */ do_action( 'bp_after_directory_members_list' ); ?> <?php bp_member_hidden_fields(); ?> <div class="pagination-links" id="member-dir-pag-bottom"> <?php //bp_members_pagination_links(); ?> </div> </div> <?php else: ?> <div id="message" class="info"> <p><?php _e( "beklager, ingen funnet", 'buddypress' ); ?></p> </div> <?php endif; ?> <?php /** * Fires after the display of the members loop. * * @since BuddyPress (1.2.0) */ do_action( 'bp_after_members_loop' ); } ?> <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> <script type="text/javascript"> var testBtnClick = function() { /* $.ajax({ //url: '_inc/ajax.php', success: function(data) { alert("fikk til"); } }); */ $.ajax({ url: '/members-loop.php', data: {action: 'test'}, type: 'post', success: function(output) { alert("Gått gjennom"); } }); } document.getElementById('lastsideBtn').onclick = testBtnClick; </script>
Hi: n00b with Buddypress, and not very experienced w/PHP hacks either.
I have a staging site where the user is prompted to choose a role (Musician or Venue) during registration. This goes well, but then I need that role to show up on the user’s new profile page. It doesn’t. Any ideas?
I’m going to include a couple of images so you can see what I’m talking about. Here’s the registration page as it appears to a brand new user (you can see this at above url as well):
You can see the “Musician or Venue? (Required)” drop-down field at the bottom-left of the above screengrab.
And here is a registered user’s profile page:
As you can see, there is no mention of “User Role” here, or either of the two values “Musician” or “Venue” associated with the profile. **I need to display the registered user’s role somewhere in this profile.**
Finally, I’m using WP 4.2.2, 2013 Theme (switched after taking screenshots, just to remove 1 variable from the equation), Buddypress 2.2.3.1, as well as WP Roles at Registration plugin.
I’m trying to get standard WP roles (subscriber, administrator, etc) to appear on the profile page next to the avatar, for each user and seen by everyone.
I’ve been searching and experimenting, but haven’t found anything that works yet.
Any suggestions for a function or maybe a snippet to put in user-details.php?
Thanks for any help.
My wordpress is 4.1 and Buddypress 2.1.1
Hello Community,
I am having a problem with a custom member page pagination, when clicking link to pagination page 2, pagination takes us to page 2 and adds the string “?upage=2” to the site URL.
After that, clicking page 1 or back symbol on pagination links does nothing, only refreshes page.
Problematic page: http://wp1.kodeserver.net/coach/
I have set the page above in Twentyfifteen theme as to exclude any third party theme related errors.If we use the default member page “http://wp1.kodeserver.net/members/” then pagination works ok.
I believe the error might be caused by the member filter i made or maybe i messed up the template.
Hope you can help.
Below is the code i am using:
functions that i use to filter member loop by member types on the site:
function bp_exclude_users_but_player() {
$excluded_users_but_player = implode(',',get_users('role=coach&fields=ID'));
$excluded_users_but_player = $excluded_users_but_player.','.implode(',',get_users('role=seniorcoach&fields=ID'));
$excluded_users_but_player = $excluded_users_but_player.','.implode(',',get_users('role=subscriber&fields=ID'));
$excluded_users_but_player = $excluded_users_but_player.','.implode(',',get_users('role=editor&fields=ID'));
$excluded_users_but_player = $excluded_users_but_player.','.implode(',',get_users('role=administrator&fields=ID'));
return $excluded_users_but_player;
}function bp_exclude_users_but_coach() {
$excluded_users_but_coach = implode(',',get_users('role=player&fields=ID'));
//$excluded_users_but_coach = $excluded_users_but_coach.','.implode(',',get_users('role=seniorcoach&fields=ID'));
$excluded_users_but_coach = $excluded_users_but_coach.','.implode(',',get_users('role=subscriber&fields=ID'));
$excluded_users_but_coach = $excluded_users_but_coach.','.implode(',',get_users('role=editor&fields=ID'));
$excluded_users_but_coach = $excluded_users_but_coach.','.implode(',',get_users('role=administrator&fields=ID'));
return $excluded_users_but_coach;
}function bp_exclude_users_but_senior_coach() {
$excluded_users_but_senior_coach = implode(',',get_users('role=player&fields=ID'));
$excluded_users_but_senior_coach = $excluded_users_but_senior_coach.','.implode(',',get_users('role=coach&fields=ID'));
$excluded_users_but_senior_coach = $excluded_users_but_senior_coach.','.implode(',',get_users('role=subscriber&fields=ID'));
$excluded_users_but_senior_coach = $excluded_users_but_senior_coach.','.implode(',',get_users('role=editor&fields=ID'));
$excluded_users_but_senior_coach = $excluded_users_but_senior_coach.','.implode(',',get_users('role=administrator&fields=ID'));
return $excluded_users_but_senior_coach;
}function bp_exclude_cc_backend_users() {
$excluded_cc_backend_users = implode(',',get_users('role=subscriber&fields=ID'));
$excluded_cc_backend_users = $excluded_cc_backend_users.','.implode(',',get_users('role=editor&fields=ID'));
$excluded_cc_backend_users = $excluded_cc_backend_users.','.implode(',',get_users('role=administrator&fields=ID'));
return $excluded_cc_backend_users;
}
Member Loop that calls member “Coach” filter:
<?php if ( bp_has_members( bp_ajax_querystring( 'members').'&exclude='.bp_exclude_users_but_coach().'&per_page=24' ) ) : ?>
And this is the problematic page template code (The one that filters by role type (coach))
<?php
/**
* The template for displaying all pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages and that
* other 'pages' on your WordPress site will use a different template.
*
* @package WordPress
* @subpackage Kleo
* @since Kleo 1.0
*/get_header(); ?>
<?php get_template_part('page-parts/general-title-section'); ?>
<?php get_template_part('page-parts/general-before-wrap'); ?>
<?php
if ( have_posts() ) :
// Start the Loop.
while ( have_posts() ) : the_post();
/*
* Include the post format-specific template for the content. If you want to
* use this in a child theme, then include a file called called content-___.php
* (where ___ is the post format) and that will be used instead.
*/
get_template_part( 'content', 'page' );
endwhile;
endif;
?><?php do_action( 'bp_before_directory_members_page' ); ?>
<section class="container-wrap main-color">
<div class="section-container container"><div id="buddypress">
<?php do_action( 'bp_before_directory_members' ); ?>
<?php do_action( 'bp_before_directory_members_content' ); ?>
<!--<div id="members-dir-search" class="dir-search" role="search">
<?php //bp_directory_members_search_form(); ?>
</div>--><!-- #members-dir-search --><?php do_action( 'bp_before_directory_members_tabs' ); ?>
<form action="" method="post" id="members-directory-form" class="dir-form">
<div id="subnav" class="item-list-tabs" role="navigation">
-
<!--<li class="selected" id="members-all">"><?php //printf( __( 'All Members <span>%s</span>', 'buddypress' ), bp_get_total_member_count() ); ?>--> <!--Contatore membri totali-->
<?php //if ( is_user_logged_in() && bp_is_active( 'friends' ) && bp_get_total_friend_count( bp_loggedin_user_id() ) ) : ?>
<!--<li id="members-personal">"><?php //printf( __( 'My Friends <span>%s</span>', 'buddypress' ), bp_get_total_friend_count( bp_loggedin_user_id() ) ); ?>-->
<?php //endif; ?><?php //do_action( 'bp_members_directory_member_types' ); ?>
<?php //do_action( 'bp_members_directory_member_sub_types' ); ?>
<!--<li id="members-order-select" class="last filter">
<label for="members-order-by"><?php //_e( 'Order By:', 'buddypress' ); ?></label>
<select id="members-order-by">
<option value="active"><?php //_e( 'Last Active', 'buddypress' ); ?></option>
<option value="newest"><?php //_e( 'Newest Registered', 'buddypress' ); ?></option><?php //if ( bp_is_active( 'xprofile' ) ) : ?>
<option value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ); ?></option>
<?php //endif; ?><?php //do_action( 'bp_members_directory_order_options' ); ?>
</select>
--></div><!-- .item-list-tabs -->
<div id="members-dir-list" class="members dir-list">
<?php
/**
* BuddyPress - Members Loop
*
* Querystring is set via AJAX in _inc/ajax.php - bp_legacy_theme_object_filter()
*
* @package BuddyPress
* @subpackage bp-legacy
*/?>
<?php if ( bp_has_members( bp_ajax_querystring( 'members').'&exclude='.bp_exclude_users_but_coach().'&per_page=24' ) ) : ?>
<div id="pag-top" class="pagination">
<div class="pag-count" id="member-dir-count-top">
<?php bp_members_pagination_count(); ?>
</div>
<div class="pagination-links" id="member-dir-pag-top">
<?php bp_members_pagination_links(); ?>
</div>
</div><?php do_action( 'bp_before_directory_members_list' ); ?>
<ul id="members-list" class="item-list row kleo-isotope masonry">
<?php while ( bp_members() ) : bp_the_member(); ?>
<?php $user_info = get_userdata(bp_get_member_user_id()); ?>
<?php
$user_roles = $user_info->roles;
$user_role = array_shift($user_roles);// echo 'User ID: ' . $user_info->ID . "\n";
// echo bp_core_get_user_displayname( $user_info->ID ) ;
// echo $user_info->ID ;
?><li class="kleo-masonry-item type-<?php echo $user_role; ?>">
ID ; ?>' value='show/hide'> <!-- link che apre info's nascoste -->
<div class="member-inner-list animated animate-when-almost-visible bottom-to-top">
<div class="item-avatar rounded">
<!-- ">
--> <?php bp_member_avatar( 'type=full&height=150&width=150' ); ?>
<!-- -->
<?php //do_action('bp_member_online_status', bp_get_member_user_id()); ?>
</div>
<!-- "> -->
<div class="item">
<div class="item-title"><span class="loop-nome"><?php bp_member_name(); ?></span><span class="loop-cognome"><?php bp_member_profile_data( 'field=Cognome' ); ?></span></div><!-- <?php if ( bp_get_member_latest_update() ) : ?>
<span class="update"> <?php bp_member_latest_update(); ?></span>
<?php endif; ?>
-->
<?php do_action( 'bp_directory_members_item' ); ?><?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' );
*/
?></div>
</div><!--end member-inner-list-->
<!-- link che apre informazioni nascoste -->
<div id="contenuto-nascosto-<?php echo $user_info->ID ; ?>" class="hidden-infos">
<div class="nascondi-infos">
ID ; ?>' value='show/hide'>
<i class="icon-cancel"></i>
</div>
<div class="unhidden-infos unhidden-infos-first ">
<div class="item-avatar-small">
">
<?php bp_member_avatar( 'type=full&height=50&width=50' ); ?>
<?php do_action('bp_member_online_status', bp_get_member_user_id()); ?>
</div>
</div>
<div class="unhidden-infos">
<div class="item-title">
">
<span class="loop-nome"><?php bp_member_name(); ?></span>
">
<span class="loop-cognome"><?php bp_member_profile_data( 'field=Cognome' ); ?></span>
</div>
</div>
<div class="unhidden-infos">
<span class="nomeazienda-titolo custom-title">Azienda:</span>
<span class="nomeazienda custom-infos"><?php bp_member_profile_data( 'field=Azienda' ); ?></span>
</div>
<div class="unhidden-infos">
<span class="pos-lavorativa-title custom-title">Funzione:</span>
<span class="pos-lavorativa custom-infos"><?php bp_member_profile_data( 'field=Funzione' ); ?></span>
</div>
<div class="unhidden-infos">
<span class="settore-title custom-title">Settore:</span>
<span class="settore custom-infos"><?php bp_member_profile_data( 'field=Settore' ); ?></span>
</div>
<div class="unhidden-infos">
<span class="laurea-title custom-title">Laurea:</span>
<span class="laurea custom-infos"><?php bp_member_profile_data( 'field=Laurea' ); ?></span>
</div><div class="action">
<div class="generic-button" id="send-private-message">
" title="Clicca per profilo completo" class="send-message">Profilo Completo
</div><?php //do_action( 'bp_directory_members_actions' ); ?>
</div>
</div><script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#nascondi-mostra-<?php echo $user_info->ID ; ?>').live('click', function(event) {
jQuery('#contenuto-nascosto-<?php echo $user_info->ID ; ?>').toggle('show');
});
});
</script><?php endwhile; ?>
<?php do_action( 'bp_after_directory_members_list' ); ?>
<?php bp_member_hidden_fields(); ?>
<?php else: ?>
<div id="message" class="info">
<p><?php _e( "Sorry, no members were found.", 'buddypress' ); ?></p>
</div><?php endif; ?>
<?php do_action( 'bp_after_members_loop' ); ?>
</div><!-- #members-dir-list -->
<?php do_action( 'bp_directory_members_content' ); ?>
<?php wp_nonce_field( 'directory_members', '_wpnonce-member-filter' ); ?>
<?php do_action( 'bp_after_directory_members_content' ); ?>
</form><!-- #members-directory-form -->
<?php do_action( 'bp_after_directory_members' ); ?>
</div><!-- #buddypress -->
</div>
</section><?php do_action( 'bp_after_directory_members_page' ); ?>
<?php get_template_part('page-parts/general-after-wrap'); ?>
<?php get_footer(); ?>
Hello to all the BuddyPress Scientists out there.
I am almost mad about to show bbPress User Role on BuddyPress Profile Page. And I am currently using this code, but it is not perfect and correct.
function show_user_role () { global $bp; $reply_id = bbp_get_reply_id( $reply_id ); $abc_role = bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) ); echo '<span class="profile-role ' . $abc_role . '"><i class="fa fa-star"></i> <em>'; echo $abc_role; echo '</em></span>'; } add_action( 'bp_before_member_header_meta', 'show_user_role' );
The demo output can be seen on http://www.punjabi.cc/ website by visiting any members profile.
First problem with this code is, it does not show correct name for dynamic roles when user is not logged in.
Second problem, the users who are blocked also tagged ‘Member’ not ‘Blocked’.
Please either correct it or provide me a another perfect piece of code, I will be highly thankful.
Regards,
LaddiHey there guys, i’m working on a website where i’m integrating s2member functionality with buddypress. I thought some of the things I’ve come across may be useful to other people.
1. Filter Users Displayed in Members Directory by s2member role.
In your plugins/buddypress/bp-templates/bp-legacy/buddypress/members/ folder edit the file “members-loop.php”. Just under
<?php do_action( 'bp_before_members_loop' ); ?>
at the top 20 lines of the file we need to write some PHP code to build a comma separated list of ID’s based on the s2member role or roles that we want. In my case I wanted only members of “s2member_level2”.
<?php $args = array ( 'role' => 's2member_level2', 'fields' => array( 'id' ) ); // The User Query $user_query = new WP_User_Query( $args ); $custom_ids = ''; for($i = 0;$i < sizeof($user_query->results); $i++){ $a = $user_query->results[$i]->id; $custom_ids .= $a.","; } ?>
Now that we’ve made a comma separated string of ids ($custom_ids), we need to pass it to the members loop.
Change
<?php if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : ?>
to
<?php if ( bp_has_members('per_page=30&type=alphabetical&'.'include='.$custom_ids ) ) : ?>
In my case I wanted to make sure atleast 30 members showed up, and that they were in alphabetical order.Done.
2. Importing s2member custom fields to buddypress fields
You may be asking; why??? Well, it turns out that when you have the s2member option to integrate with buddypress it doesn’t actually import it’d data to the buddypress tables. It just binds it’s self to the ‘Base’ group, Which will show up by default in buddypress profiles. When it doesn’t import to the buddypress tables, it was very difficult for me to manipulate how the information showed up. Particularly the fact that I have the users give me their address information, and I don’t want that to even be an option to show in user profiles.
So instead of using s2member to integrate automatically, I wrote a function that would check a users information when they login. If they have certain information in s2member that is not in their BP Profile, it will add it automatically.
in functions.php add the code:
<?php add_action('wp_head','s2_profile_field_update',10,2); function s2_profile_field_update() { global $current_user; get_currentuserinfo(); if( get_user_field("s2member_login_counter") < 1000 ) { if( current_user_is("s2member_level2") ) { if(xprofile_get_field_data('Nationality',$current_user->id) == '' && get_user_field('nationality') != '') { xprofile_set_field_data('Nationality', $current_user->id, get_user_field('nationality')); } } } } ?>
You can change Nationality to what ever the name is of the extended BP field (in users>profile fields).
And of course you can duplicate the if statements for how every many fields you want to import from s2memeber -> BP.
Also note thatif(get_user_field("s2member_login_counter") < 1000)
mean’s that this process will run for any user that logs in with membership role s2member_level2 and has logged in less than 1000 times. I used 1000 times because I want any member at this moment who logs in to have their profiles populated. In the future I will drop it down to 1 or 2.I’ll post more as I gather it. But in the mean time I hope this helps some people.
\M