Forum Replies Created
-
You’d just need to find the ‘id’ or ‘class’ selector of the group names and use either padding or margin property in your CSS file (style.css). The developer tools in your browser can help identify it (F12 button in your browser)
In reply to: Users Login QuestionI think by default user can see the admin panel, but custom code can be used to prevent anyone but admin from using it (that’s the route I’ve taken).
(Can’t answer the blog post/images bit as I’m not allowing users to do that)
Hi @mikee1001,
Did you insert the php functions above into functions.php or bp-custom.php? The code works in both but it is preferable to put BuddyPress specific modifications in the bp-custom.php file (remember the
<?phpand?>tags).Do you have other functions in the same file where you are inserting this code which are working correctly even if the bubble functions aren’t?
In reply to: Hide activities of the administratorThis might help (change ID from 1 in the appropriate places to the ID of your administrator(s). ID’s found in your database ):
https://buddypress.org/support/topic/hide-all-admins-from-all-buddypress-activities/
Those selectors were based on the Themeforest demo site, so they may not match your actual site. Without seeing your site its not possible to say. So you’ll have to use f12 to find out if its correct.
Did you try ctrl-A without including any new bubble or top-menu CSS to see if anything was there?
Did you insert the correct name of your menu in the php code?Hi mikee1001,
No worries :). I’m not familiar with that theme. But from your demo link (used the first of the three demos), the selector might be either:
.top-bar ul>li.bubbleor.top-bar ul>li.has-dropdown.bubble.This assumes that your live version of the theme is set up like their demo though. Note that I have added the
.bubble. As a check if you remove that bit from the selector and add something likeborder= 1px solid red;you should see a change on your site. If not then the selector is wrong.Have you got the bubbles appearing successfully somewhere on the page (even though you haven’t got the correct selector yet)? Check by pressing ctrl-A to select all, which highlights everything on your site in blue, then you can look for the numbers which are your notification counters etc. If you can’t see them then something may have been done wrongly and would need to be addressed prior to finding the correct CSS selectors.
If you manage to get them appearing and put a link to your site then I could tell you what the correct selector is.
Hi @mikee1001,
The code i used for inserting the bubble counters for notifications, unread messages and total friends is:
// Notification counter bubble function bptest_main_nav_notification_bubble( $items, $args ) { if( $args->theme_location == 'header-menu' ) { // In manage locations via WP Dash>Appearance>Menus $items_array = array(); while ( false !== ( $item_pos = strpos ( $items, '<li', 3 ) ) ) { $items_array[] = substr( $items, 0, $item_pos ); $items = substr( $items, $item_pos ); } $items_array[] = $items; array_splice( $items_array, 3, 0, '<li class="bubble">' . bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) . '</li>' ); // 0,0 1st position, 1,0 2nd, etc $items = implode( '', $items_array ); } return $items; } add_filter( 'wp_nav_menu_items', 'bptest_main_nav_notification_bubble', 10, 2 );// Unread message counter bubble function bptest_main_nav_message_bubble( $items, $args ) { if( $args->theme_location == 'header-menu' ) { // In manage locations via WP Dash>Appearance>Menus $items_array = array(); while ( false !== ( $item_pos = strpos ( $items, '<li', 3 ) ) ) { $items_array[] = substr( $items, 0, $item_pos ); $items = substr( $items, $item_pos ); } $items_array[] = $items; array_splice( $items_array, 5, 0, '<li class="bubble">' . bp_get_total_unread_messages_count( bp_loggedin_user_id() ) . '</li>' ); // 0,0 1st position, 1,0 2nd, etc $items = implode( '', $items_array ); } return $items; } add_filter( 'wp_nav_menu_items', 'bptest_main_nav_message_bubble', 10, 2 );// Total friends counter bubble // Note, 'bp_friend_get_total_requests_count' will give the total connection request count if desired function bptest_main_nav_friend_bubble( $items, $args ) { if( $args->theme_location == 'header-menu' ) { // In manage locations via WP Dash>Appearance>Menus $items_array = array(); while ( false !== ( $item_pos = strpos ( $items, '<li', 3 ) ) ) { $items_array[] = substr( $items, 0, $item_pos ); $items = substr( $items, $item_pos ); } $items_array[] = $items; array_splice( $items_array, 7, 0, '<li class="bubble">' . friends_get_total_friend_count( bp_loggedin_user_id() ) . '</li>' ); // 0,0 1st position, 1,0 2nd, etc $items = implode( '', $items_array ); } return $items; } add_filter( 'wp_nav_menu_items', 'bptest_main_nav_friend_bubble', 10, 2 );In each of the above you will want to change the
theme_location == 'header-menu'totheme_location == 'INSERT YOUR HEADER MENU NAME HERE'. The name of your menu is found via your WP Dashboard > Appearance > Menus. The three functions above were inserted into bp-custom.php .The positions of the bubbles will also need changing depending on where they should be in your menu. Do that by changing the numbers on the section
array_splice( $items_array, 7, 0, '<li class="bubble">'. The comment alongside the line in the code should help you.You’ll also need some CSS for the bubbles otherwise you probably won’t see them even if they are functioning. If you hit ctrl-A to select everything on your web page, they should show up somewhere in your menu (assuming the code has been implemented correctly of course).
As you can see in the functions above all the bubbles have been given a class called “bubble”. So put in your style.css (of your child theme) something like:
#main-navigation .main-nav ul li.bubble { transform: translate(0, 50%); width: 20px; height: 20px; padding: 2px 6px; border: 1px solid #000; border-radius: 50%; margin: 0 10px 0 0; background: #fff; color: #000; font-size: 11px; }The selector (
#main-navigation .main-nav ul li.bubble) may be different on your site because it will depend on your theme etc. So use the developer tools, F12 button, on your browser to find out the correct one. It will be the bit before the.bubblethat is different.Hopefully the above helps!
In reply to: Compose Private Message IssueAh makes sense, should’ve seen that! Cheers @shanebp
In reply to: Members connecting with eachotherHi@dave8528,
Not 100% sure what you mean. Do you mean that you had done some custom CSS styling of the buttons which have not been applied to the new one you just created?
If so then where you have inserted the code
<div id="another-friend-button">…etc into your cover-image-header.php, just replace theid="another-friend-button"part with whatever ID or Class you have used on your other buttons.In reply to: Spam registrations – how to stop them?!Hi @JackJJW,
Not used either on a live site as mine is still in development locally, but read good things about the plugins WP-SpamShield Anti-Spam and Wangguard. May be worth looking into.
In reply to: Members connecting with eachotherHi @dave8528,
Replying to your q in the other thread here. Firstly if you aren’t already doing so, make sure whatever changes/amendments to code are done in a child theme if you aren’t doing so already (Google search WordPress Child Themes).
Just checked the code and it seems to be working fine. You may not be seeing the button if you have cover images activated on your profile pages? If you do, the file you want is “cover-image-header.php” The member-header.php is used when cover images aren’t active. Was just using it as an example location.
In reply to: Members connecting with eachotherJust replied to another post which might be what you are after….see below. Saves me typing it out again 🙂
https://buddypress.org/support/topic/missing-add-friend-button/
In reply to: Missing Add Friend ButtonHi @missgridiron,
Add this to your bp-custom.php:
function add_another_friend_button() { $user_id = get_the_author_meta( 'ID' ); $mybutton = bp_add_friend_button( $user_id ); if ( ( is_user_logged_in() && ! bp_is_my_profile() ) ) { echo $mybutton; } } add_action( 'button_here', 'add_another_friend_button' );Then add the code below to wherever you want the button to appear (e.g. in the member-header.php file of your child theme if you want a button in your profile page header):
<div id="another-friend-button"> <?php do_action( 'button_here' ); ?> </div><!-- #another-friend-button -->for reference: https://buddypress.org/support/topic/add-friend-button-everywhere/
In reply to: Members connecting with eachother@dave8528 , do you just mean a button on a profile page used for adding friends that says “Connect”?
In reply to: Buddypress SecurityThanks @shanebp & @henrywright 🙂
In reply to: How to display a custom field?Oh and you can use some <span> (see earlier posts) to get control style wise
In reply to: How to display a custom field?Hi David,
Copying the code method does work. (Renaming the function, the variables/fields within and the add_action bits).
Just tried this out too and it appears to work fine, though not tested thoroughly so you’d need to double check:
function bptest_show_a_field () { $user_id = bp_loggedin_user_id(); $field_one = xprofile_get_field_data( 'Field One', bp_loggedin_user_id(), $multi_format = 'comma' ); $field_two = xprofile_get_field_data( 'Field Two', bp_loggedin_user_id(), $multi_format = 'comma' ); if ( ! $field_one && ! $field_two ) { return; } else { echo $field_one ; echo $field_two ; } } add_action ( 'user_a_field', 'bptest_show_a_field' );Then put
do_action ( 'user_a_field' );in your desired location.In reply to: How to display a custom field?Got there in the end thanks to Shane 🙂
In reply to: How to display a custom field?Hi David,
I just tried this (note ive used the ‘Location’ field as that is what i have as a field):
function bptest_show_opleiding_field () { $user_id = bp_loggedin_user_id(); $opleiding_field = xprofile_get_field_data( 'Location', bp_loggedin_user_id(), $multi_format = 'comma' ); if ( ! $opleiding_field ) { return; } else { echo $opleiding_field ; } } add_action ( 'user_opleiding_field', 'bptest_show_opleiding_field' );Tested with this in the cover-image-header.php
<div id="fieldId"> <?php do_action ( 'user_opleiding_field' ); ?> </div>This shows up fine when used on my site. Try this with the do_action in your order.php? Hope it works
In reply to: How to display a custom field?Hi David,
Can’t see any errors in your code, so it should work for BuddyPress (try the do_action within a BP file to double check). Hopefully Shane’s suggestions will work for you!
In reply to: CSS causing cover image to disappear.Ahh I see. I haven’t used that approach personally for my custom CSS. Just got the one CSS file (style.css) for everything at the moment, WP Theme and BuddyPress. I use comments and sections to organise it.
I can only think of a few things to try, though you probably have done these already (ensure the cover image option is ticked in the WP dashboard):
1. Remove all your custom CSS files temporarily and see if the cover image appears by default. If it does, then the problem is probably isolated to your CSS rather than with BuddyPress or your main Theme.
2. Use the browser developer tools (F12) to see if the id for cover image appears in the code even if you can’t see anything on screen. If it does try manipulating its attributes to bring it to the foreground as it may be hidden beneath other layers (z-index). Or display: none layers around it to see what is hiding it.
3. Check the id’s against your CSS. New id’s were obviously introduced for the cover image which weren’t in old BuddyPress CSS files which you may have used as a base for your custom one.
4. Try another theme with your custom CSS to see if it is a theme issue
5. Put all your custom BuddyPress CSS into the standard style.css file within a child theme and see if it works that way.In reply to: How to display a custom field?Hi,
Not used LearnPress so unable to comment much on that . The method I used to insert/display my own custom profile fields into a header on the user activity page was as follows (in this case, a Location field which was created in the WP dashboard).
1. Add to bp-custom.php :
//Add Location field to header if user has entered data into it //Nothing is shown if user hasn't entered anything into field function bptest_show_location_field () { $location_field = bp_get_member_profile_data( 'field=Location' ); if ( ! $location_field ) { return; } else { echo '<span class="custom-field-text">' . $location_field . '</span>'; } } //user_bio_location_field is used within the member-header php template file add_action ( 'user_location_field', 'bptest_show_location_field' );2. In my member-header.php file (which was copied into my child theme) entered the div :
<div id="user-location"> <?php do_action ( 'user_location_field' ); ?> </div><!-- #user-location - function is found in bp-custom -->Obviously the php code in step two is placed wherever you want the field to display, just put it in the correct location of the correct php file. In my case it was member-header.php but for you i’m guessing its the one that generates your order page?.
Not sure if you have already tried any of that or if it even helps!
In reply to: CSS causing cover image to disappear.Maybe I’m misunderstanding you, not sure from your description whether or not you have already created a child theme with your own CSS file?
https://codex.wordpress.org/Child_Themes
You can just make all your styling changes in that instead of copying various whole CSS files from the BuddyPress folders (and your changes will be kept whenever WP or BP are updated).
Also double check the box for cover photo is ticked on your WP dashboard if you want your users to be able to use them.
Great! Thanks @danbp
In reply to: Suppressing rich text on xprofile text area