Forum Replies Created
-
After a lot of searching I’ve put this together. It appears to remove the ability of normal site users to use the rich text area editor in ‘multi line text areas’. Its use now allows jQuery functions for character limits to be applied to the text area which was not possible when tinymce was active.
function bptest_remove_tinymce() { if ( !is_super_admin() ) { tinymce.activeEditor.getBody().setAttribute( 'contenteditable', false ); } } add_action( 'wp_footer', 'bptest_remove_tinymce' );Note that the
is_super_admin()is included. Without it the WP bar at the top of the screen which is used to access dashboard etc disappears.Then to remove the remaining Visual/Text tabs attached to the text area, use the CSS
display:noneon the relevant div id.I am still very curious as to whether there are better methods for excluding the rich text editor / tinymce from Buddypress (across the site and/or targeting specific text areas). Would appreciate any input from anyone more in the know!
Thanks
In reply to: Hide ‘Members’ page from all except Adminπ
In reply to: Hide ‘Members’ page from all except AdminWould a redirect do? –
//Prevents non admin users seeing pages function bptest_restrict_bp_pages() { global $bp; if( !is_super_admin() && bp_is_members_directory() ) { bp_core_redirect( $bp->root_domain ); } } add_action( 'get_header', 'bptest_restrict_bp_pages' );In reply to: Redirect users who aren’t logged inHi,
Maybe using this would help stop users who aren’t logged in seeing things you don’t want them to in the first place (and therefore they won’t be able to try and access it). Not really the redirect solution you are after but it may be of use. Works with BuddyPress (I don’t use bbPress).
//Prevents non logged in users seeing pages other than those permitted function bpcustom_restrict_bp_pages() { global $bp; //These pages are permitted to logged out users if( bp_is_blog_page() || bp_is_register_page() || bp_is_activation_page() ) { return; } if( !is_user_logged_in() ) { bp_core_redirect( $bp->root_domain ); } } add_action( 'get_header', 'bpcustom_restrict_bp_pages' );In reply to: Profile Field Text Area Max Character or Word LengthHi @danbp thanks for reply.
Tried the code you wrote in the link above and it works fine. But as with the one referenced in my first post it reduces the string length upon display rather than preventing the user typing in a large number of characters in the first place (and the data being stored in database).
So moved onto looking at the code snippet by @henrywright for the sign up page. Would be suitable if i could convert it to work with profile fields. Got to this stage with a few q’s:
function my_textarea_validation() { $custom_field_id = bp_get_member_profile_data( 'field=Mini Bio' ); //is the use of $_POST['field_' . $custom_field_id] correct to access desired profile field? if ( strlen( $_POST['field_' .$custom_field_id] ) > 5 ) { global $bp; //which $bp->... error message to use? $bp->signup->errors['field_'] = __( 'CUSTOM ERROR MESSAGE', 'buddypress' ); } } //which hook to use? (to affect the textarea on Profile > Edit navigation tab) add_action( '???', 'my_textarea_validation' );These might help you @antoinegdln4:
[Resolved] Position Notification Counter Bubble after Specific Navigation Tab ID
https://buddypress.org/support/topic/help-customising-admin-bar-removing-links-from-dropdown/
or removing WP admin bar entirely to all users except admin:
function remove_admin_bar() { if ( !current_user_can( 'administrator' ) && !is_super_admin() ) { show_admin_bar(false); } } add_action( 'after_setup_theme', 'remove_admin_bar' );Hey @osisis,
Glad to see you sorted it. This was my code:
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 id="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 );I gave it the ID ‘bubble’. You can obviously give it a class if you want too (class=”bubbles”).
Hi @leanneoleary,
I can help with your first q (if your’e still looking). Add to your bp-custom file:
//WP Admin Bar - Remove edit-profile tab from dropdown menu function remove_admin_bar_edit_profile( $wp_admin_bar ) { $wp_admin_bar->remove_node( 'edit-profile' ); } add_action( 'admin_bar_menu', 'remove_admin_bar_edit_profile', 999 );To remove the activity, substitute ‘activity’ wherever it says ‘edit_profile’ in code above. note also the ‘my-account-activity’ eg:
//WP Admin Bar - Remove activity tab from dropdown menu function remove_admin_bar_activity( $wp_admin_bar ) { $wp_admin_bar->remove_node( 'my-account-activity' ); } add_action( 'admin_bar_menu', 'remove_admin_bar_activity', 999 );for profile: sub in ‘xprofile’ and ‘my-account-xprofile’
for notifications: sub in ‘notifications’ and ‘my-account-notifications’
for messages: sub in ‘messages’ and ‘my-account-messages’
for friends: sub in ‘friends’ and ‘my-account-friends’
for settings: sub in ‘settings’ and ‘my-account-settings’In reply to: Changing the text color on the Registration pageIf you add the code below to your style.css file it won’t appear on the page:
#buddypress .field-visibility-settings-notoggle { display: none; }Thanks @danbp, exactly what i needed to position the counter bubbles! Both snippets worked great.
I updated the theme_location arg in the second to get it to work with my menu and added an ID to allow the CSS. Thanks again!For anyone looking to do the same with the messages and friends request counters, replace the:
bp_notifications_get_unread_notification_countwith
bp_get_total_unread_messages_countorbp_friend_get_total_requests_countas needed.All the code I’ve used is in the post above. Not required any custom functions.
The function:
bp_notifications_get_unread_notification_count( bp_loggedin_user_id() )was mentioned here:https://buddypress.org/support/topic/how-to-get-notification-count-code/
Just echoing that function in my child header.php gives me exactly what i needed (along with the CSS i posted). Everything works fine.
The only issue is to locate it within the menu itself in the correct location after the Notification tab, which i cannot do in the header file. At the moment I am only able to locate it within the container that holds the menu.
The menu I am using I have created via WP > Appearance > Menus. Just a bog standard menu in the header of the page.
hi @danbp,
I saw it, didn’t take anything from the code in the last post. Am i missing something?
Or are you referring to the guy who said to build the menu manually?
In reply to: Change subnav slugGreat π
In reply to: Change subnav slugYeah that’s why I’ve left it as is. Everything interlinked.
Opened a ticket as per your recommendation!
In reply to: Logout redirect from WP admin bar (may be useful)p.s. Reason i needed it in first place was because i wanted the wp admin bar logout to match that of my Buddypress logout buttons.
In reply to: Some basic Questions before installing BuddyPress.I think it does that by default yeah (i say ‘think’ because I’ve been customizing for a little while now and can’t remember 100% what is default). But I’m fairly sure, 95%, that what you are describing is default.
I’ve basically started from zero knowledge on Buddypress and used the forum & Codex for help to progress. Other users and moderators have usually posted relevant stuff and have helped me out on things too. So no php skills shouldn’t hurt unless you want to customize heavily. Lots of code is scattered around the forums.
In reply to: Change slug without touching core files?That’s quite an interesting document, especially the infographic. Would never have know it existed.
Personally I have found using the forum is more user friendly and written at a more understandable level than the Codex. It’s also up to date and returns far more results for a given search when compared to the Codex.
But knowing that BP is volunteer run is a very valid reason for things being outdated etc. It’s great that there’s a resource base for it in the first place. I’m sure many people like me who are new to BP wouldn’t get half as far in a given time frame without it!
In reply to: How to stop Spam Users from registeringI’ve seen a few places mention this plugin:
https://wordpress.org/plugins/wangguard/
(not actually used any myself as site isn’t live yet)
In reply to: Some basic Questions before installing BuddyPress.Just bear in mind what Dan said though, ‘if you know how’.
It really depends on what you want to do, the level to which you want to customise etc. So CSS and PHP skills are likely needed unless you decide on changing v little. There are documents and the support forum though where people have done stuff and posted how to do stuff or various pieces of code etc. (that’s what I’ve been using).
In reply to: Some basic Questions before installing BuddyPress.No worries
In reply to: Some basic Questions before installing BuddyPress.Yeah you can have an activity page (or Home as you are calling it) showing activities of people you are friends with.
Personally I see the whole ‘friends’ thing as just a connection between two members. So you can ‘friend request’ and become ‘friends’ with the person and have their stuff appear on an activity page. But you can use various tools to change ‘friends’ to be ‘follow’ or ‘colleague’ or whatever you feel like. Hence why I see it as a ‘connection’ because you can call it whatever you want depending on what site you are building.
In reply to: Change slug without touching core files?Yeah I bet it is a big task. All you guys are doing a great job at it nevertheless so congrats!
If I get sufficient knowledge to contribute I will. Right now in these early days of using it i am nowhere near qualified! (Simultaneously learning/hacking away at php :s).
I guess by asking the various questions that I have been and/or putting the code on the forum etc. the snippets of knowledge I gain is shared with anyone else looking to do similar.
In reply to: Remove Everything GravatarThanks for the explanation @danbp. Ahhhh the Mystery Man ha.
WP is using get_avatar and BP substitute it with his own code for internal purpose.
So if i understand you, WP calls for the user’s Gravatar regardless via
get_avatarand Buddypress then just takes it from WP to make it appear on the user profile? Therefore the codeadd_filter('bp_core_fetch_avatar_no_grav', '__return_true');only stops the second part of the process where Buddypress requests the user’s Gravatar from WP. That right?Deactivating Gravatar will also deprive the people who use the service to get their usual picture on your site. Itβs not an innocent decision.
Yeah I agree. The reasons I have now for wanting to prevent access to Gravatar is for data/privacy/3rd party website reasons and also slowdown (if the user numbers did reach certain levels). I don’t want to ‘force’ them to upload a profile pic because I want them to give as little or as much to their profile as they feel like (which is why I wouldn’t use the Buddydev force profile pic plugin either).
In reply to: Change slug without touching core files?So what appears to be happening is that the Buddybar adopts the slug changes immediately (I’ve just removed the display:none CSS for the main nav tabs on Buddybar to check because I don’t use it).
But the top menu (created via the Menus in WP Dashboard) is where the tabs are disappearing due to the slug changes. Tried with
define ( 'BP_MESSAGES_SLUG', 'notes' );to confirm it wasn’t an isolated effect. All is fine there now though, they just need replacing into the menu via the WP Dash once the slug has been changed and then they appear again.Are the slugs of subnav tabs changed using the define code too? I haven’t come across it.
Out of interest, have I misunderstood this link where it says the various defines at the bottom are deprecated, or is it just in need of updating? :
In reply to: Change slug without touching core files?I tell a lie…it works on the ‘friends activity loop’ (not sure what the name is, the activity loop filtered to show updates from your friends), but it also makes the ‘my friends’ tab and page disappear (the section showing WHO i am friends with).