Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'display user role on profile page'

Viewing 25 results - 26 through 50 (of 83 total)
  • Author
    Search Results
  • sven1988xyz
    Participant

    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.

    #254124
    welsh10
    Participant

    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

    #253789

    In reply to: Profile Tabs

    nnyorker
    Participant

    Hi Dan –
    Thank you for your reply. I have tried this plugin, but there is a conflict with the edit profile page where all the Field User groups are displayed instead of only the role that the user has registered for. I have not had any luck getting it resolved. The view page is fine. I just don’t want students when they edit their profile to see all the other tabs that are only specific to Teachers, Coaches, Parents.
    Thanks again.

    had_hc
    Participant

    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!

    #252271
    had_hc
    Participant

    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.

    kory27
    Participant

    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.4

    #246705
    scoobs2000
    Participant

    Hi
    in short everything you have asked can be done.

    But I’m a little bias as I honestly believe regarding technology there is nothing that can’t be achieved it just comes down to how much time and budget you have to invest… 🙂

    Below is a bit of a ramble…. But might provide insight. after you organize your coffee and come back.

    I have nearly completed a project that sounds similar in nature (few weeks from launch in final beta testing), however it was a highly customised solution (private membership site) .
    With nearly 70 plugins, 100’s hours coding integration code (lots of trial and error) between the plugins and also compatibility tests with multiples of plugins to ensure no issues, because of slow load times the project requires deploying from CDN,fast servers and customised caching solutions.
    most of work load appeasr to be bbpress – so an near out of the box solution, you prob don’t need to go that far.

    But not to scare you. Here are some pointers that might answer your questions, based on my understanding of the OP.

    In my case I spent many months researching solutions with many platforms (open source / paid / managed premium) – buddy press was selected simply because is built on WordPress that’s already has the core abilities you need, you just need to “hook in to’em” and take advantage of this concept – you can keep working on bettering and adding separate components / features as time goes by, great for client, works out a bit cheaper in the startup phase and great for developer – land ya self a permanent support / ongoing development contract……

    Is it possible to update profile content/meta? : In general yes, buddy press allows this out of the box

    Either the user or the admin can update, you can have admin only fields (the user doesn’t access them – but the admin can)
    if you use a membership plugin eg, s2member – you can extend this idea much further eg, only require email on signup, then all other fields are accessible from profile and can set fields on a per membership level,

    In your case, you might have different profile fields for students, teachers, Parents and only require a couple of basic fields to be completed on signup and all other fields can still be “required” when they reach their profile page.
    For profile field management I recommend the s2membership pro plugin (free version available) http://s2member.com/

    My project has a “todo list” for each and every member – however I’m still to this day unable to find a plugin that interacts with a completed wp/bbp/buddypress site. So I had to code one. The todo list was designed / engineered in a way that interacts with “wordpress” in general, by storing a completely unique data feed much like the activity feed with time stamps and can be programmed to be linked to any site link, media download, page view, forum post, reply any activity on the site can be logged and applied to the feed which the to-do-list interacts with and auto completing (crossing of the item) each item also has dependencies, so you rattle off a list of activities before the task is crossed off and each to-do-list also has dependencies so it is not seen by a user until certain tasks are completed, eg, purchase a course from the store, or complete a previous to-do-list.

    In short: Yes it can be done, however I’m not aware of any 3rd party plugin that does this successfully.

    In my case I have the to-do-list shown in the sidebar so as a member goes through the tasks the list is also available to them no matter what page they are on. But possible to publish it in the profile page if required.

    Regarding email notices, I recommend looking into the woo commerce sensei http://www.woothemes.com/products/sensei/ plugin for your courses that way you have management of email notices, in fact prob most of the things you require will be available via sensei – note this is a premium paid plugin with yearly ongoing licence costs.
    Without a free trial version to try before you buy.

    But maybe gravity forms developer licence might be fine in your case as it has, gateway plugins, qiz and survey plugins – it would be possible to build certain simple courses on the gravity framework including delivery of custom emails – if building a form based system than certainly worth a look into – but would require a developers licence to get all the plugins you would prob require.

    In fact what I do is use gravity forms email chimp plugin to send the members email address to an email list (automation campaign) in mail chimp (paid account) that auto sends a welcome emails that I have customize to suit the activity they have completed, this way I can send pretty html + marketing emails + scheduled follow up emails and take the work load off WordPress other than a quick API connect on demand.

    Regarding: is it possible to have multiple logins or users access the same account/profile?
    In simple: Yes, but it all comes to context of the profile, will each member be able to see other members profiles or will parents be able to edit a child profile etc.

    Although my project does not require the need for 2 or more members to edit a single profile, I do have multiple levels of context (horizontal and vertical memberships) all with their own set of rules who profiles they can see and what buddypress features are available to them – some members don’t have activity feeds or messages, But I needed to ensure that members that do have access to these features can’t access the features of cross membership and so on.

    This is 100% custom code (no plugin) but while coding this up I recall thinking I’m 100% confident it is possible to add another level of check “if current user can edit displayed user” and go from there, all you would need is a profile field / meta that links multiple accounts together –
    Eg, a parent account has a profiled field “child user name” – they just enter the child username / user ID – and now we would add the profile check if a parent is viewing the child’s profile.

    Regarding paying a deposit, and payment, this is my findings.

    There was no single one membership / payment plugin that integrated perfectly into what I wished to achieve – I have tested many. please note I’m suggesting there are no plugins that do this stuff just none that achieved the outcomes I needed for my project.

    – Tips: – start the project design based on the payment systems / gateway (the complete project and direction of development is 100% dependent on this) because the simple reason every feature you implement needs to check “is a paid member and what level (cap / role) ” – including free membership with paid features “is not a paid member” but has paid for… this includes recurring and non-recurring subscriptions with consideration of what you intend to do if a subscription expires.

    Eg, a recurring subscription will either just auto subscribe and pay for the next time frame (or fail)
    A non-reoccurring subscription will auto expire after a given time frame (or X cycles)

    The difference between to the two –
    Is generally on a recurring subscription when it expires it also linked to a member account to “do something” eg downgrade membership

    A non-recurring subscription is generally used for a onetime payment you have access forever feature- eg, a course and resources, you pay once on a deposit, subscription over several weeks when the subscription expires the member still has access to the course as long as they remain at minimum a free member on the site. (anyhow that’s how I have implemented things)

    These two concepts are completely different in the way they interact with the member as well at many levels although on the surface appear to be almost the same, add in a deposit feature you are also opening another level of context to play with, mostly limiting the available options regarding the payment gateway service you will need to use or more so which services have this feature on offer.

    As mentioned – my suggestion is start with the gateway solutions first and reverse the design back to the front end. – this is the big lesson I took away with this project (4 rewrites in total) as it was always a block relating to the gateway limitations (and laws relating to online subscriptions in my country).

    My project:
    Woo commerce (free) for shopping cart system including purchase of courses, subscription to site and deposit/ subscription to courses, plus all other products, deliverable products, workshops, webinars, one on one sessions, resource downloads from pdf to videos. Anything you can think off can be sold through woo

    Woo commerce quick cart – plugin (paid)– now I can add a buy now button on any page for any product including subscriptions – the membership info page has a standard 3 column price comparison chart with nothing more than a “sign up now” button – clicking the button auto adds the subscription to cart and opens the checkout popup with one click and without leaving the page (no need to send to store)

    Sensei (paid)– for courses and fits well into woo commerce system (but requires a couple more plugins and custom integration code if implementing paid / subscription based courses )

    Groups plugin (free) to easily manage roles and caps (as I have to teach client staff how to do this and manage the site) WordPress has this capability built in if your a coding ninja (I’m not)

    Groups Woo commerce (paid plugin) to link groups to a purchase – apply a role / cap or groups of, to a user based on the purchase.

    Then some custom code is required – to perform a check and if a user has a particular role or cap than apply the s2membership level – this check is done at the store level so if a member cancels or defaults on a payment – the membership level is auto adjusted depending on what role or cap is supplied to the user from the groups woo commerce automation. groups plugin manages non-recurring subscriptions so a expired subscription does not remove the users caps and roles (but a default on payment does)

    S2member pro – for membership level management including profile fields management and most importantly complete site access management – I can apply access to each and every competent of the site this includes , forums, topics, replies, posts, pages, media, courses, and content within pages eg, home page displays different content based on the membership level / logged in or general public. s2member pro is also used to override default bbpress / buddy visibility settings eg, hidden forums only available to certain member levels – but requires custom code to apply or traverse access levels on submitting topics / replies to ensure widgets and other snippets don’t display private areas to members that don’t have access. (it allows you to write custom queries with zero concern or consideration to access levels)

    For subscriptions (paid)– I use woo commerce Subscriptions plugin – this manages on its own site access based on paid recurring subscriptions (or in simple turns on or off user account based on payment) – pay x amount monthly to access certain site features, courses and resources, forums, pages, blog articles etc.

    However – woo commerce subscriptions does not manage deposit / time based subscriptions (non-recurring subscriptions) eg, pay a deposit for a course and gain instant access then pay off on a subscription for x amount of weeks / months –
    I was not able to find any plugin (free or paid) that does this, so I had to write a plugin currently under experimental concept stage.

    Other tips: often it’s better to find compatible, well supported and pay for premium plugins that have overlapping features and disengage these features you don’t want to achieve your goals and do as little integration code as possible, but anything you do needs to be well planned and though out as to not to touch core code in any platform, framework or plugin.
    At the end of the day you want the ability to upgrade all systems as time go by.

    Eg, s2member plugin has its build in membership system that is “required to be active” for the plugin to work. – all I did was setup a single paid (never to be used membership) on a paypal sandbox store this includes setting up all the s2membership registration pages etc – then put a simple redirect in the .htaccess on any of these pages. Now to purchase membership you must go to the store (woo commerce) and purchase a subscription via woo – s2member has now has nothing to do with membership registration / payment systems.

    And of course I have “force account creation” turned on at the store – you cannot make a purchase without signup at a minimum free site membership.
    by disengaging the buddy, bbp, Wp, and all other means of registering (by redirect) but only leaving the woo commerce customer account registration available – The pop up registration form I use for free members is just a woocommerce customer account registration form (with no products attached) with a fallback to the s2membership cut down reg form (in case ajax / jquery etc not working on client side)

    And now all purchases, subscriptions, shop account, courses etc are now available from the buddy press profile page also via a “woo to buddypress” plugin (or in my case built into the theme)

    May sound complicated but as mentioned I would really suggest starting with payment solutions and nut out this part of the project first as this will most likely force development direction,

    one of my project goals was a solution that can cater for anything…. so,

    Regarding variable deposit / costs amounts based on user input – if using similar approach as I did – you would just setup woo commerce discount codes per variable outcome / result and would just reveal the correct coupon code to the user on the checkout page. they just cut and paste this code into the discount field and click apply.

    or setup up multi products – one product per price base. – have the user input their details first and the result would be – apply a groups cap / role then only offer the courses products in the store with the associated price base based on user caps / role –

    woo discount coupons can be setup on multiple bases – eg, deposit amount / on going subscription amount or total amount or per product or per cart total etc.

    for me was plenty of research into this including concept builds of other community platforms and as above is only a bit of a sample of features used relating to the OP.
    I was under very strict key point goals and achievements requiring very specific outcomes many of these affected development direction how / why I implemented the above.

    There may be better simpler ways to suit your specific project, but thought it might be worth a mention for some direction. or at least insight into some of the plugins I use / ideas and concepts.

    my usual disclaimer – if there is something in there for you, that’s great! if not that’s fine too!

    enjoy!

    #246607
    gurusurfer
    Participant

    Just so to be clear since you mentioned the class!

    I am not trying to show the image for paid members visitors here. I want to add an image for the member profile for any user to see when they land on their profile page.

    If you are not familiar with the above tag, do you have a suggestion how I can display an image icon for user profiles of custom role?

    Many thanks

    rpandassociates
    Participant

    I 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 storefront

    I 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

    #244990
    shanebp
    Moderator

    Untested, but try:

    function jake_nav_remove($nav_array) { 
    	
        if( ! bp_is_my_profile() ) {
    
             $roles = wp_get_current_user()->roles;
    
             if (in_array('Supporter', $roles)) 
                 $nav_array = '';
        }
    
        return $nav_array;
    }
    add_filter('bp_get_displayed_user_nav_activity', 'jake_nav_remove', 10, 1 );
    add_filter('bp_get_displayed_user_nav_profile', 'jake_nav_remove', 10, 1 );

    However – removing these tabs can create problems – ‘profile’ is the default tab ( and therefore screen ) for member pages. You’ll need to decide on which tab should be default, since you may remove profile and activity.

    #244047
    chriotte
    Participant

    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.
    mockup

    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>
    
    
    danbp
    Moderator

    Please read here to show WP’s user roles:

    https://buddypress.org/support/topic/displaying-user-roles-in-profile/

    Musician and venue are not roles, but member types which is a different thing. For that read here:
    https://buddypress.org/support/search/display+user+role+on+profile+page/

    danbp
    Moderator

    Yes indeed, there is a way.

    Step by step tutorial with example code which you add to bp-custom.
    Note: use this code as is and follow the instruction. Once you understood what it does and how it works, you will be able to modify it to your needs.

    First, create a new xprofile field in the first group field (aka Base Group and containing Name as default field). Only fields created in that group are visible on the register page. Call it Type, enter description and choose multiselectbox as field type. Add operator, vendor, coach as select option.

    That’s all for the register part handled by BuddyPress.

    Now we need to declare the whole thing to get it work on front-end.
    Member-type is an additionnal functiony to select members by… type ! Not by role, not by latest, mst popular or anything else. Just (for the moment) by a custom type of your choice.

    We have to built a member directory for our types. We have 3 types and they will be shown on 3 new tabs on that directory.

    1) we formally declare the member types
    2) we count members by type (to stay correctly informative on the directory)
    3) we display the tabs

    function using_mt_register_member_types() {
    	bp_register_member_type( 'operator', array(
    		'labels' => array(
    			'name'          => __( 'Operators', 'using-mt' ),
    			'singular_name' => __( 'Operator', 'using-mt' ),
    		),
    	) );
    
    	bp_register_member_type( 'vendor', array(
    		'labels' => array(
    			'name'          => __( 'Vendors', 'using-mt' ),
    			'singular_name' => __( 'Vendor', 'using-mt' ),
    		),
    	) );
    
    	bp_register_member_type( 'coach', array(
    		'labels' => array(
    			'name'          => __( 'Coaches', 'using-mt' ),
    			'singular_name' => __( 'Coach', 'using-mt' ),
    		),
    	) );
    }
    add_action( 'bp_init', 'using_mt_register_member_types' );
    
    function using_mt_count_member_types( $member_type = '', $taxonomy = 'bp_member_type' ) {
    	global $wpdb;
    	$member_types = bp_get_member_types();
    
    	if ( empty( $member_type ) || empty( $member_types[ $member_type ] ) ) {
    		return false;
    	}
    
    	$count_types = wp_cache_get( 'using_mt_count_member_types', 'using_mt_bp_member_type' );
    
    	if ( ! $count_types ) {
    		if ( ! bp_is_root_blog() ) {
    			switch_to_blog( bp_get_root_blog_id() );
    		}
    
    		$sql = array(
    			'select' => "SELECT t.slug, tt.count FROM {$wpdb->term_taxonomy} tt LEFT JOIN {$wpdb->terms} t",
    			'on'     => 'ON tt.term_id = t.term_id',
    			'where'  => $wpdb->prepare( 'WHERE tt.taxonomy = %s', $taxonomy ),
    		);
    
    		$count_types = $wpdb->get_results( join( ' ', $sql ) );
    		wp_cache_set( 'using_mt_count_member_types', $count_types, 'using_mt_bp_member_type' );
    
    		restore_current_blog();
    	}
    
    	$type_count = wp_filter_object_list( $count_types, array( 'slug' => $member_type ), 'and', 'count' );
    	$type_count = array_values( $type_count );
    
    	if ( empty( $type_count ) ) {
    		return 0;
    	}
    
    	return (int) $type_count[0];
    }
    
    function using_mt_display_directory_tabs() {
    	$member_types = bp_get_member_types( array(), 'objects' );
    
    	// Loop in member types to build the tabs
    	foreach ( $member_types as $member_type ) : ?>
    
    	<li id="members-<?php echo esc_attr( $member_type->name ) ;?>">
    		<a href="<?php bp_members_directory_permalink(); ?>"><?php printf( '%s <span>%d</span>', $member_type->labels['name'], using_mt_count_member_types( $member_type->name ) ); ?></a>
    	</li>
    
    	<?php endforeach;
    }
    add_action( 'bp_members_directory_member_types', 'using_mt_display_directory_tabs' );

    We also need to sort the members list on each type tab using the loop scope.

    function using_mt_set_has_members_type_arg( $args = array() ) {
    	// Get member types to check scope
    	$member_types = bp_get_member_types();
    
    	// Set the member type arg if scope match one of the registered member type
    	if ( ! empty( $args['scope'] ) && ! empty( $member_types[ $args['scope'] ] ) ) {
    		$args['member_type'] = $args['scope'];
    	}
    
    	return $args;
    }
    add_filter( 'bp_before_has_members_parse_args', 'using_mt_set_has_members_type_arg', 10, 1 );

    And we finally clean the cache to stay up to date with the output

    function using_mt_clean_count_cache( $term = 0, $taxonomy = null ) {
    	if ( empty( $term ) || empty( $taxonomy->name ) || 'bp_member_type' != $taxonomy->name )  {
    		return;
    	}
    
    	wp_cache_delete( 'using_mt_count_member_types', 'using_mt_bp_member_type' );
    }
    add_action( 'edited_term_taxonomy', 'using_mt_clean_count_cache', 10, 2 );

    That’s all for a members directory page showing All Members and tabed Members by type.

    If you want to show the type of a member on his profile header, use this:

    function using_mt_member_header_display() {
    	$member_type = bp_get_member_type( bp_displayed_user_id() );
    
    	if ( empty( $member_type ) ) {
    		return;
    	}
    
    	$member_type_object = bp_get_member_type_object( $member_type );
    	?>
    	<p class="member_type"><?php echo esc_html( $member_type_object->labels['singular_name'] ); ?></p>
    
    	<?php
    }
    add_action( 'bp_before_member_header_meta', 'using_mt_member_header_display' );

    Or if you want to display the type under each user avatar on the member directory, you can use this snippet. Note: was originally made to add a geoloc shortcode below the member type. I let it as is, so you can see how it’s done.

    function who_are_you_directory() { // by member_type name + geoloc (wpgeo me)
    $user = bp_get_member_user_id();
    $terms = bp_get_object_terms( $user,  'bp_member_type' );
    
    	if ( ! empty( $terms ) ) {
    		if ( ! is_wp_error( $terms ) ) {		
    				foreach( $terms as $term ) {
    					echo '<p>' . $term->name . '</p>'; 					
    					echo do_shortcode('[gmw_member_info]');
    				}		
    		}
    	} 
    
    }
    add_filter ( 'bp_directory_members_item', 'who_are_you_directory' );

    Anything inspired by Codex and heavy topics reading.

    Member Types

    Members Loop

    May this help.

    andrew55
    Participant

    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.

    evitorino
    Participant

    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/&#8221; 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(); ?>

    #234013
    Mathieu Viet
    Moderator

    Interesting discussion 🙂

    First i’ll explain why i’m using bp_is_active( 'activity' ) : it’s just an extra check to be absolutely sure the activity component is active. I do it because BuddyPress is a set of components you can activate / deactivate from the BuddyPress settings. So if the activity component is not active, no need to add Post Type activities. And when you develop a BuddyPress plugin, you need to remember there can be configs that deactivated the component you are extending.

    Second, about the contexts argument. In this codex page https://codex.buddypress.org/plugindev/post-types-activities/ i’m describing a bit his role
    Here https://codex.buddypress.org/themes/activity-dropdown-filters-in-templates/ i’m talking about the way we are getting the activity types since BuddyPress 2.1 And finally reading this page https://codex.buddypress.org/developer/function-examples/bp_activity_set_action/ you will see the interest of the contexts argument.
    In short the contexts argument is a way to control where you want an option (activity action) to be displayed. For instance if you want to include an option into the single group’s home page dropdown filter you do contexts => array( 'group' )

    In the case of a post type, i think in most cases there’s not a great interest to have the activity filter in the group’s single home page because in most cases the post type have been created out of a BuddyPress group (mainly in WP Admin actually). That’s why in my example i suggest to use 'contexts' => array( 'activity', 'member' ), ‘activity’ means display the dropdown option into the activity directory and ‘member’ display it into the member’s profile. The ‘member’ context is interesting in the case of Post Types activities because a post type is always created by a user_id.

    Now with the question “could it be possible to display Post type activities into a given group’s stream ?” we must understand this part 'component_id' => 'activity' Here you are defining the component you want the Post type activities to be linked to. So you could say cool! lets put ‘groups’ to have activities in groups. But here you’d be wrong because all generated activities would be displayed in the first group the one having the id #1 (If multisite it could give another illusion…) Why id #1, because it’s the id of the blog where was created the post type. So you would need to have a different value depending from which group the post type was posted. As in core we don’t include a feature to post a post type from a group, by default we are setting the item_id field to the current blog.

    Unless you want to arbitrary display the activity in one particular group, i’d say this need should only concern Plugins extending the Groups component. Of course it’s possible, and i’ve done it for one of my plugin.

    I hope my explanations will help you @youmin.

    laddi
    Participant

    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,
    Laddi

    Henry Wright
    Moderator

    Hi @screampuff

    You could try the following function which will stop unwanted users from viewing the page directly if they tried typing the URL:

    function my_hide_achievements_page() {
        $role = xprofile_get_field_data( 'Membership' );
    
        if ( ( $role != 'Administrator' ) || ( bp_current_user_id() == bp_displayed_user_id() ) )
            return;
    
        // I guess we should 404 this page because this member isn't an admin or the displayed member.
        $wp_query->set_404();
        status_header( 404 );
        nocache_headers();
    }
    add_action( 'init', 'my_hide_achievements_page' );
    #229903
    miama
    Participant
    
    
    <?php
    
    /**
    * BuddyPress – Users Home
    *
    * @package BuddyPress
    * @subpackage bp-default
    */
    
    //get theme options
    global $oswc_bp;
    
    //set theme options
    $oswc_bp_sidebar_unique = $oswc_bp[‘bp_sidebar_unique’];
    $oswc_bp_members_sidebar_unique = $oswc_bp[‘bp_members_sidebar_unique’];
    
    //setup variables
    $sidebar=”Default Sidebar”;
    if($oswc_bp_sidebar_unique) { $sidebar=”BuddyPress Default Sidebar”; }
    if($oswc_bp_members_sidebar_unique) { $sidebar=”BuddyPress Members Sidebar”; }
    
    get_header( ‘buddypress’ ); ?>
    
    <div class=”main-content-left”>
    
    <div class=”page-content” id=”content”>
    
    <?php do_action( ‘bp_before_member_home_content’ ); ?>
    
    <div id=”item-header” role=”complementary”>
    
    <?php locate_template( array( ‘members/single/member-header.php’ ), true ); ?>
    
    </div><!– #item-header –>
    
    <div id=”item-nav”>
    <div class=”item-list-tabs no-ajax” id=”object-nav” role=”navigation”>
    
        <?php bp_get_displayed_user_nav(); ?>
    
        <?php do_action( ‘bp_member_options_nav’ ); ?>
    
    </div>
    </div><!– #item-nav –>
    
    <div id=”item-body”>
    
    <?php do_action( ‘bp_before_member_body’ );
    
    if ( bp_is_user_activity() || !bp_current_component() ) :
    locate_template( array( ‘members/single/activity.php’ ), true );
    
    elseif ( bp_is_user_blogs() ) :
    locate_template( array( ‘members/single/blogs.php’ ), true );
    
    elseif ( bp_is_user_friends() ) :
    locate_template( array( ‘members/single/friends.php’ ), true );
    
    elseif ( bp_is_user_groups() ) :
    locate_template( array( ‘members/single/groups.php’ ), true );
    
    elseif ( bp_is_user_messages() ) :
    locate_template( array( ‘members/single/messages.php’ ), true );
    
    elseif ( bp_is_user_profile() ) :
    locate_template( array( ‘members/single/profile.php’ ), true );
    
    elseif ( bp_is_user_forums() ) :
    locate_template( array( ‘members/single/forums.php’ ), true );
    
    elseif ( bp_is_user_settings() ) :
    locate_template( array( ‘members/single/settings.php’ ), true );
    
    elseif ( bp_is_user_notifications() ) :
    locate_template( array( ‘members/single/notifications.php’ ), true );
    // If nothing sticks, load a generic template
    else :
    locate_template( array( ‘members/single/plugins.php’ ), true );
    
    endif;
    
    do_action( ‘bp_after_member_body’ ); ?>
    
    </div><!– #item-body –>
    
    <?php do_action( ‘bp_after_member_home_content’ ); ?>
    
    </div>
    
    </div>
    
    <div class=”sidebar”>
    
    <?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar($sidebar) ) : else : ?>
    
    <div class=”widget-wrapper”>
    
    <div class=”widget”>
    
    <div class=”section-wrapper”><div class=”section”>
    
    <?php _e(‘ Made Magazine ‘, ‘made’ ); ?>
    
    </div></div>
    
    <div class=”textwidget”>
    
    <p><?php _e( ‘This is a widget panel. To remove this text, login to your WordPress admin panel and go to Appearance >> Widgets, and drag & drop a widget into the corresponding widget panel.’, ‘made’ ); ?></p>
    
    </div>
    
    </div>
    thats what I did:
    </div>
    
    <?php endif; ?>
    
    </div>
    
    <br class=”clearer” />
    
    <?php get_footer( ‘buddypress’ ); ?>
    
    #229137
    Myg0t
    Participant

    Hey 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 that if(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

    #207114
    1a-spielwiese
    Participant

    Yes, there should be a way, but I was not able to follow the instructions / to realise that way.

    The basic idea is:

    • Create two (or more) new WordPress user roles, e.g.: Users-UK and Users-USA.
    • Then you can assign one xProfile-field, ‘In which [federal] state do you live?’, exclusively to your users with the user role Users-USA; and another x-Profile, ‘In which county do you live?’, to your users with the user role Users-UK.

    The instructions for that solution you find there:

    https://buddypress.org/support/topic/resolved-different-profile-types-and-different-user-roles/

    (The user roles there are ‘bands’ and ‘fans’).

    And my report about my attempt to apply that instructions you find there:

    https://buddypress.org/support/topic/different-profile-types-and-different-user-roles-part-ii/

    My user roles are (sport) ‘teams’ and ‘fans’.

    But unfortunately, I was not able to hinder, that ‘fans’ get displayed the questions (xProfile-fields) for ‘teams’ was well; and the ‘teams’ the questions for ‘fans’…

    Further problem:

    Even if there is a solution regarding later profile edits – even complicate seems to be, to make already the registration page “input senstive”, because during registration the new user isn’t yet registered (i.e.: has no user role yet).

    Cfr. there:

    http://forum.wpde.org/buddypress/133961-registrierungsseite-umgestalten-anleitung-und-fragen.html (section 4. – unfortunately in German).

    #203649
    1a-spielwiese
    Participant

    Let’s come back to the beginning:

    1st: Revolved.

    2nd: Resolved.

    a) I decided finally for having only one border color. If you want to have different border colors, you have to make different definitions for #buddypress .standard-form #basic-details-section and #buddypress .standard-form #profile-details-section

    and, if you use them, for: #user-role-section and #buddypress .standard-form #blog-details-section.

    b) I have abstained from having the text lines ‘WordPress’ respec. ‘BuddyPress’ at the borders and from making the bottom-borders more strong.

    3rd: Revoled.

    4th: Revolved.

    5th:

    I guess, it would be most comfortable, to have within the Dashboard check boxes for deciding, whether a certain field group or field should be displayed on registration page or not.

    Not revolved.

    6th to 8th:

    a) Finally I have abstained from having the blog-details-section on the registration page.

    b) I didn’t collect information about changing this section.

    —-

    So, the main issues are revolved. I would have no objections against marking the entire thread as ‘[Resolved’].

    #203615
    1a-spielwiese
    Participant

    I found two more solutions:

    1st:

    a) The place of the field for determining the user role is depending on the plugins/wp-roles-at-registration/wp-roles-at-registration.php

    The relevant line of the original version of that file is:

    add_action('bp_after_signup_profile_fields', array($wp_rar_plugin, 'bp_choose_roles_registration_form'));

    I substituted there bp_after_signup_profile_fields by template_notices and now the field at issue is displayed not the end, rather at the beginning of my registration page:

    http://1a-spielwiese.de/registrieren/

    b)

    For creating the headline and the introductory text I made a second change within the same file. I changed the following section. The first and the last line of the quote is the original code, and the lines inbetween I inserted:

        <div class="register-section" id="user-role-section">
        
        <h4-a><?php _e( 'Benutzer/in/rolle', 'buddypress' ); ?></h4-a>
    
        <p><small><em>Entscheide Dich bitte als allererstes f&uuml;r eine der Benutzer/in/rollen "Team" oder "Fan" (bitte w&auml;hle nicht die Rolle "Subscriber"; diese Angabe soll noch gel&ouml;scht werden). In Abh&auml;ngigkeit von Deiner Antwort wirst Du nach Abschluss der Registrierung und wenn Du Dich das erste Mal bei 1a-Spielwiese einloggst und Dir Dein Profil ansiehst, die M&ouml;glichkeit haben, einige erg&auml;nzende rollenspezifische Profilangaben zu machen.</em></small></p>
    
        <label for="wp_rar_user_role"><?php echo $this->wp_rar_role_label; ?></label>

    2nd:

    As well I was able to integrate now not only the ‘base’-profile field group. For that it is neccessary to copy a long section of the buddypress register.php. This sections begins with:

    			<?php /***** Extra Profile Details ******/ ?>
    
    			<?php if ( bp_is_active( 'xprofile' ) ) : ?>
    
    				<?php do_action( 'bp_before_signup_profile_fields' ); ?>
    
    				<div class="register-section" id="profile-details-section">
    
    					<h4><?php _e( 'Profile Details', 'buddypress' ); ?></h4>
    
    					<?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?>
    
    					<?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 1, 'fetch_field_data' => false ) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>

    And it ends with:

    					<input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_field_ids(); ?>" />
    
    					<?php endwhile; endif; endif; ?>
    
    					<?php do_action( 'bp_signup_profile_fields' ); ?>
    
    				</div><!-- #profile-details-section -->
    
    			<?php endif; ?>

    The only two things, which are obligatory then:

    • You have to insert the entire copied section behind the last line of the original section.
    • And you have to change 'profile_group_id' => 1, into 'profile_group_id' => 2, (for adressing your second profile field group – and so on regarding the further profile field groups).

    Besides I changed the <h4>-headline and inserted introductory text behind that headline. Therefore my code there is:

    					<h4-a><?php _e( 'Profile Details - Teil II: Kontaktendaten', 'buddypress' ); ?></h4-a>
    
    				<p><small><em>Beachte bitte, dass Du in zu den Profilfeldern in diesem Abschnitt selbst entscheiden kannst, wem Deine Angaben, die machst, angezeigt werden sollen.</small></em></p>
    #202778
    1a-spielwiese
    Participant

    I decided to test theses instructions – and in general they work.

    My registration page has now a new design:

    http://1a-spielwiese.de/registrieren/

    This result I got using two means:

    1st:

    I tested with ‘Simple Custom CSS’-Plugin that code:

    #buddypress .standard-form #basic-details-section, #buddypress .standard-form #blog-details-section, #buddypress .standard-form #profile-details-section {
        border: 2px solid #8b008b;
    	float: none;
      	clear: left;
      	width: 100%;
      	padding: 10px;
      	margin-bottom: 1em;
    }
    
    #user-role-section {
      	border: 2px solid #8b008b;
        float: none;
        width: 100%;
      	padding: 10px;
    }
    
    #wp_rar_user_role {
          width: 100%;
        }
    
    h4-a {
    	color: #8b008b;
    	font-size: 11px;
    	font-size: 1.1rem;
      	font-weight: bold;
    	letter-spacing: 0.05em;
    	line-height: 1.9091;
    	text-transform: uppercase;
    }
    
    .wp-editor-container {
        border: 1px solid #DCDCDC;
    }

    Finally I will insert it into my child-theme.

    2nd:

    The relecant section of the register.php with in my reddle-child/buddypress/members-folder is now:

    		<?php if ( 'request-details' == bp_get_current_signup_step() ) : ?>
    
    			<?php do_action( 'template_notices' ); ?>
    
    			<p><?php _e( 'Mitglied bei 1a-Spielwiese zu werden, ist sehr einfach - und kostenlos. F&uuml;lle einfach die Felder unten aus und wir erstellen f&uuml;r Dich umgehend ein Benutzer/in/konto und in K&uuml;rze auch einen eigenen Blog (Webseite).', 'buddypress' ); ?></p>
    
    			<?php do_action( 'bp_before_account_details_fields' ); ?>
    
    			<div class="register-section" id="basic-details-section">
    
    				<?php /***** Basic Account Details ******/ ?>
    
    				<h4-a><?php _e( 'Account Details', 'buddypress' ); ?></h4-a>
    
    				<p><small><em>Diese Daten werden f&uuml;r Deine Registrierung als neues Mitglied und die Einrichtung Deines eigenen Blogs (Webseite) ben&ouml;tigt.</em></small></p>
    
    				<label for="signup_username"><?php _e( 'Username', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    				<?php do_action( 'bp_signup_username_errors' ); ?>
    				<input type="text" name="signup_username" id="signup_username" value="<?php bp_signup_username_value(); ?>" />
    
    				<label for="signup_email"><?php _e( 'Email Address', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    				<?php do_action( 'bp_signup_email_errors' ); ?>
    				<input type="text" name="signup_email" id="signup_email" value="<?php bp_signup_email_value(); ?>" />
    
    				<label for="signup_password"><?php _e( 'Choose a Password', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    				<?php do_action( 'bp_signup_password_errors' ); ?>
    				<input type="password" name="signup_password" id="signup_password" value="" class="password-entry" />
    				<div id="pass-strength-result"></div>
    
    				<label for="signup_password_confirm"><?php _e( 'Confirm Password', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    				<?php do_action( 'bp_signup_password_confirm_errors' ); ?>
    				<input type="password" name="signup_password_confirm" id="signup_password_confirm" value="" class="password-entry-confirm" />
    
    				<?php do_action( 'bp_account_details_fields' ); ?>
    
    			</div><!-- #basic-details-section -->
    
    			<?php do_action( 'bp_after_account_details_fields' ); ?>
    
    			<?php /***** Extra Profile Details ******/ ?>
    
    			<?php if ( bp_is_active( 'xprofile' ) ) : ?>
    
    				<?php do_action( 'bp_before_signup_profile_fields' ); ?>
    
    				<div class="register-section" id="profile-details-section">
    
    					<h4-a><?php _e( 'Profile Details', 'buddypress' ); ?></h4-a>
    
    				<p><small><em>Diese Daten werden k&uuml;nftig in Deinem Profil angezeigt. Einige Angaben sind verpflichtend, um aussagekr&auml;ftige Profile zu erhalten; bei anderen Formularfeldern ist es Dir selbst &uuml;berlassen, ob Du Angaben machst oder nicht.</small></em></p>
    
    					<?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?>
    
    					<?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 1, 'fetch_field_data' => false ) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
    
    					<?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
    
    						<div<?php bp_field_css_class( 'editfield' ); ?>>
    
    							<?php
    							$field_type = bp_xprofile_create_field_type( bp_get_the_profile_field_type() );
    							$field_type->edit_field_html();
    
    							do_action( 'bp_custom_profile_edit_fields_pre_visibility' );
    
    							if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?>
    								<p class="field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
    									<?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?> <a href="#" class="visibility-toggle-link"><?php _ex( 'Change', 'Change profile field visibility level', 'buddypress' ); ?></a>
    								</p>
    
    								<div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id() ?>">
    									<fieldset>
    										<legend><?php _e( 'Who can see this field?', 'buddypress' ) ?></legend>
    
    										<?php bp_profile_visibility_radio_buttons() ?>
    
    									</fieldset>
    									<a class="field-visibility-settings-close" href="#"><?php _e( 'Close', 'buddypress' ) ?></a>
    
    								</div>
    							<?php else : ?>
    								<p class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
    									<?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?>
    								</p>
    							<?php endif ?>
    
    							<?php do_action( 'bp_custom_profile_edit_fields' ); ?>
    
    							<p class="description"><?php bp_the_profile_field_description(); ?></p>
    
    						</div>
    
    					<?php endwhile; ?>
    
    					<input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_field_ids(); ?>" />
    
    					<?php endwhile; endif; endif; ?>
    
    					<?php do_action( 'bp_signup_profile_fields' ); ?>
    
    				</div><!-- #profile-details-section -->
    
    				<?php do_action( 'bp_after_signup_profile_fields' ); ?>
    
    			<?php endif; ?>
    
    			<?php if ( bp_get_blog_signup_allowed() ) : ?>
    
    				<?php do_action( 'bp_before_blog_details_fields' ); ?>
    
    				<?php /***** Blog Creation Details ******/ ?>

    3nd:

    Nevertheless I have two questions regarding the design:

    a) Why the 100%-width for #wp_rar_user_role is ignored?

    b) How can I place the third section (‘Mitglieder-Kategorie’) above the other two sections (or between the other two sections)?

    4th:

    I recognised as well: Deleting there:

    <?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 1, 'fetch_field_data' => false ) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>

    'profile_group_id' => 1, results in getting not only displaying the ‘base group’ of the xProfile fields, rather all fields of all field groups. 🙂

    Questions:

    a) How can I get the names (titels) of the different xProfile field groups displayed as well?

    b) How can I ensure, that only new members, which choose the user role ‘team’, get displayed the profile fields for teams and new members, which choose the user role ‘fan’, get displayed the profile fields for fans?

Viewing 25 results - 26 through 50 (of 83 total)
Skip to toolbar