Search Results for 'custom activity page'
-
AuthorSearch Results
-
November 4, 2017 at 2:05 pm #268823
Topic: Login Issues
in forum How-to & TroubleshootingMike
ParticipantWordpress 4.8.3, BuddyPress 2.9.2, self hosted on an Apache (shared) server.
I really want this to work but I install WP and BP without errors. I set ‘activity’ as a static front page. I test the site (there are no other users) and all looks OK.
I logout. I login. The page still appears to be logged out. The page doesn’t refresh to the ‘activity’ page with me as logged in.
I have tried with themes twentyfifteen, sixteen and seventeen.
I’ve searched the entire internet for a solution, not just here, and many people suggest redirect plugins. I’ve tried a few but it doesn’t work for me.
Some solutions suggest bp_custom code. I tried and it didn’t work.
The only solution I sort of found for myself was to place a “who’s online” widget on the page. After I login (and appear logged out) I click the link in the widget to my profile page. Then I can return to the home page and see I am logged in, BUT even that sometimes fails.
Please, someone, tell me what causes this incorrect login issue and how to finally resolve it.
November 3, 2017 at 4:53 pm #268805In reply to: set a default tab for non friends
David Cavins
KeymasterWhat about using a custom member front page? Then you’d have total flexibility:
Custom Front Pages for your users profilesOtherwise, I think you could conditionally filter
bp_displayed_user_get_front_templateto specifymembers/single/activity.phpfor self and friends andmembers/single/profile.phpfor non-friends. See this function:
https://buddypress.trac.wordpress.org/browser/tags/2.9.2/src/bp-members/bp-members-template.php#L1397November 1, 2017 at 7:18 pm #268759Topic: Custom tab and content on BP profile
in forum How-to & Troubleshootingdeanljbirch
ParticipantThank you in advance for any help given on this…
The aim…
- What we’d like is to add a new top level tab (such as Activity, Profile & Notifications) entitled “Add content”.
- The “Add content” tab should have the following sub-navigation sections… “Create article”, “Create event”, “Create vacancy” & “Create Service Listing”.
- Each of the tabs above should only be visible to the logged in user on their own profile.
We’ll be including front-end publishing forms in each tab.
Let’s be honest…
If you feel that this would cause any issues, be too much hassle or just wouldn’t work, please feel free to tell me straight as there is an alternative method I can use (Creating specific pages requiring login etc).August 1, 2017 at 6:11 pm #267331In reply to: 2.9 Group description turncoated
Joost abrahams
Participant1. Which version of WordPress are you running?
4.8
2. Did you install WordPress as a directory or subdomain install?
directory
3. If a directory install, is it in root or in a subdirectory?
root
4. Did you upgrade from a previous version of WordPress? If so, from which version?
No
5. Was WordPress functioning properly before installing/upgrading BuddyPress (BP)? e.g. permalinks, creating a new post, commenting.
Yes
6. Which version of BP are you running?
2.9
7. Did you upgraded from a previous version of BP? If so, from which version?
2.8.2
8. Do you have any plugins other than BuddyPress installed and activated? If so, which ones?
Ban Hammer: 2.6
bbPress: 2.6-rc-3
BP Blog Author Profile Link: 2.8.1
BP Idea Stream: 1.0.1
BP XProfile WordPress User Sync: 0.6.4
BuddyDrive: 2.1.1
BuddyPress: 2.9.0
BuddyPress Docs: 1.9.4
BuddyPress Edit Activity: 1.0.8
BuddyPress Groups Extras: 3.6.9.1
Co-Authors Plus: 3.2.2
Jetpack by WordPress.com: 5.1
JetPack Non-Admin Removal: 3.0
Login Site Icon: 1.0
Mantablog bp register text: 0.1
Mantablog bp remove rss: 0.1
Mantablog Custom Profile: 0.1
Mantablog meta desc homepage: 0.1
MediaPress: 1.1.6
Registration Honeypot: 1.1.0-alpha-1
SEO โ Remove H1: 1.0.2
TablePress: 1.8
TinyMCE Advanced: 4.6.3
WP Idea Stream: 2.4.0
WP Revisions Control: 1.2.1
WP Sitemap Page: 1.69. Are you using the standard WordPress theme or customized theme?
standard WordPress theme
10. Which theme do you use ?
Generatepress
11. Have you modified the core files in any way?
No
12. Do you have any custom functions in bp-custom.php?
No
13. If running bbPress, which version? Or did your BuddyPress install come with a copy of bbPress built-in?
2.6rc3
14. Please provide a list of any errors in your serverโs log files.
15. Which company provides your hosting?
16. Is your server running Windows, or if Linux; Apache, nginx or something else?
Linux; Apache
July 28, 2017 at 12:30 am #267240Eric Thomas Weber
ParticipantHi! I did follow the documentation. You’re right that those two pages work. Both of those pages use a certain template within the theme. That template uses a full-width page, without the sidebar and search bar that are on other pages. I’ve a few things to see what can remedy the matter:
1) Yes, I switched to a different template to test, and yes, on the 2016 template, BP works, so I don’t need to reinstall BP or get it working on its own. That part is working. I didn’t realize I’d have to reset all of my widgets and stuff. Fortunately, they weren’t deleted… Got those set up again.
2) I tried making all other relevant pages, creating pages for the stuff that BP uses, and setting each of those to use the template that works for Activity, Members, and Chapters. That didn’t work, though.
3) I tried creating a Custom CSS entry that uses the .buddypress class, telling it to use full-width for #primary. That made the page use full-width, but it didn’t make the functionality of BP work… Like on this page:
https://www.philosophersinamerica.com/chapters/create/step/group-details/Please help! I’ve reached out to my theme’s creator – and there’s no changing to a different theme. We’re super committed and it works really well for everything else, and he’s had no experience using BuddyPress. I need help! This is just the plugin I’ve been looking for to help my people create groups that they need to manage.
It seems to me that if we’re able to get some of the pages to work there’s GOT to be a way to get other relevant pages to use whatever that same setting is to work also. Any help would be hugely appreciated.
Best,Eric
June 28, 2017 at 1:01 pm #266747xavi3r12
ParticipantI have tried that it still returned the same error, however i have just noticed that if i delete my bp-custom.php everything works fine but my pages does not redirect users to there profile “if logged in” which was the purpose of the bp-custom.php file. This in the code in my bp-custom.php file
<?php // hacks and mods will go here /* Redirects to profile upon login */ add_action('login_form', 'redirect_after_login'); function redirect_after_login() { global $redirect_to; if (!isset($_GET['redirect_to'])) { $redirect_to = get_option('activity'); // sample-page = your page name after site_url } } function bp_help_redirect_to_profile(){ global $bp; if( is_user_logged_in() && bp_is_front_page() ) bp_core_redirect( get_option('home') . '/members/' . bp_core_get_username( bp_loggedin_user_id() ) . '/activity' ); } add_action( 'get_header', 'bp_help_redirect_to_profile',1); add_action('wp_logout','go_home'); function go_home(){ wp_redirect( home_url() ); exit(); } add_action( 'bp_complete_signup', 'buddydev_redirect_after_signup' ); function buddydev_redirect_after_signup() { $page = wp_redirect( get_option('siteurl') . '/profile' ); bp_core_redirect( site_url( $page ) ); } ?>So how do i fix this?? I need help Please
May 31, 2017 at 7:11 pm #266220shirleyddsn
ParticipantAnother Update:
Ok, I was finally able to create a change in the file I was trying to edit. For some reason, I wasn’t able to insert code in the exact place I was trying to last time, but I WAS able to add code elsewhere in the document.
Also, I noticed the name of the hook started with “bp”, so I moved my cover-image code to my bp-custom.php file in my child theme. But it didn’t work there either. I feel like there’s something else I’m supposed to do with
$settings['callback']. Or maybe I’m supposed to plug some more code in elsewhere. I could really use some help with this.Also, while playing with the profile templates, I noticed there were a few hooks (which I’m learning are the ‘actions’ I’m adding to) that don’t really seem to do anything but sit there. Do they exist only for me to add code to through my bp-custom.php? If so, why wouldn’t I just hard-code something into the template file?
For example:
do_action( 'bp_member_header_actions' );sits between the @username andlast-activity. But it’s empty. When the profile page loads, there’s nothing there. So that would make it an empty hook for me to plug stuff into, right?bp_profile_header_metais also empty. Are all hooks like that? Or do any of them have their own code/functions?I would still like to know where these actions are declared, and what possible functions lie inside them. Is there any way to find that information out? People create their own BP themes and plugins all the time so there has to be a way to figure this stuff out . . .
April 30, 2017 at 12:42 pm #265734In reply to: Custom Post Type Tracking
Nahum
Participantwell I was trying post the my code, but I think I spammed myself after trying to edit the reply to this …
CPT (and custom title thing)add_action('init', 'video_register_my_cpt'); function video_register_my_cpt() { register_post_type('video', array( 'label' => 'Videos', 'description' => 'Latest Videos', 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 5, 'show_in_nav_menus' => false, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array('slug' => 'videos'), 'query_var' => true, 'has_archive' => true, 'exclude_from_search' => false, 'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes','buddypress-activity'), 'bp_activity' => array( 'component_id' => buddypress()->blogs->id, 'action_id' => 'new_video', 'format_callback' => 'bp_blogs_format_activity_action_new_blog_post', 'comment_action_id' => 'new_video_comment', 'comment_format_callback' => 'bp_activity_format_activity_action_custom_post_type_comment', 'contexts' => array( 'activity', 'member' ), 'position' => 40, ), 'taxonomies' => array('video_category','video_tag'), 'labels' => array( 'name' => 'Videos', 'singular_name' => 'Video', 'menu_name' => 'Videos', 'add_new' => 'Add Video', 'add_new_item' => 'Add New Video', 'edit' => 'Edit', 'edit_item' => 'Edit Video', 'new_item' => 'New Video', 'view' => 'View Video', 'view_item' => 'View Video', 'search_items' => 'Search Videos', 'not_found' => 'No Videos Found', 'not_found_in_trash' => 'No Videos Found in Trash', 'bp_activity_admin_filter' => __( 'New video published', 'custom-domain' ), 'bp_activity_front_filter' => __( 'Videos', 'custom-domain' ), 'bp_activity_new_post' => __( '%1$s added <a href="%2$s">[Video]</a>', 'custom-domain' ), 'bp_activity_new_post_ms' => __( '%1$s added <a href="%2$s">[Video]</a>','custom-domain' ), 'bp_activity_comments_admin_filter' => __( 'Comments about video', 'custom-domain' ), // label for the Admin dropdown filter 'bp_activity_comments_front_filter' => __( 'Video Comments', 'custom-domain' ), // label for the Front dropdown filter 'bp_activity_new_comment' => __( '%1$s commented on a <a href="%2$s">video</a>', 'custom-domain' ), 'bp_activity_new_comment_ms' => __( '%1$s commented on a <a href="%2$s">[Video]</a>, on the site %3$s', 'custom-domain' ) ) ) ); } function my_video_include_post_type_title( $action, $activity ) { if ( empty( $activity->id ) ) { return $action; } if ( 'new_video' != $activity->type && 'new_video_comment' !=$activity->type ) { return $action; } preg_match_all( '/<a.*?>([^>]*)<\/a>/', $action, $matches ); if ( empty( $matches[1][1] ) || '[Video]' != $matches[1][1] ) { return $action; } $post_type_title = bp_activity_get_meta( $activity->id, 'post_title' ); if ( empty( $post_type_title ) ) { switch_to_blog( $activity->item_id ); $post_type_title = get_post_field( 'post_title', $activity->secondary_item_id ); // We have a title save it in activity meta to avoid switching blogs too much if ( ! empty( $post_type_title ) ) { bp_activity_update_meta( $activity->id, 'post_title', $post_type_title ); } restore_current_blog(); } return str_replace( $matches[1][1], esc_html( $post_type_title ), $action ); } add_filter( 'bp_activity_custom_post_type_post_action', 'my_video_include_post_type_title', 10, 2 );BP CUSTOM
/*////////////////////////////////////////////////////////////////////////////////////////////*/ // Modifying CPT Activity Actions /*///////////////////////////////////////////////////////////////////////////////////////////*/ function record_blogpost_activity_action( $activity_action, $post, $post_permalink ) { global $bp; if( $post->post_type == 'jobs' || get_post_type($post->ID) == 'jobs' ) { $activity_action = sprintf( __( '%1$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>'); } elseif( $post->post_type == 'video' || get_post_type($post->ID) == 'video' ) { $activity_action = sprintf( __( '%1$s posted a video', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' ); } elseif($post->post_type == 'post' ) { $activity_action = sprintf( __( '%1$s posted a blog', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' ); } return $activity_action; } add_filter('bp_blogs_activity_new_post_action', 'record_blogpost_activity_action', 11, 3); /*////////////////////////////////////////////////////////////////////////////////////////////*/ // Modifying CPT Comment Activity Actions /*///////////////////////////////////////////////////////////////////////////////////////////*/ function comment_activity_action( $activity_action, $post, $post_permalink ) { global $bp; if( $post->post_type == 'post' ) { $activity_action = sprintf( __( '%1$s commented on %2$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' ); } elseif( $post->post_type == 'video' || get_post_type($post->ID) == 'video' ) { $activity_action = sprintf( __( '%1$s replied on the video %2$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . esc_url( $post_permalink ). '">' . $post->post_title . '</a>' ); } return $activity_action; } add_filter('bp_blogs_activity_new_comment_action', 'comment_activity_action', 11, 3); /*//// ? /////*/ function bbg_record_video_post_type_comments( $post_types ) { $post_types[] = 'video'; return $post_types; } //add_filter( 'bp_blogs_record_post_post_types', 'bbg_record_video_post_type_comments' ); //add_filter( 'bp_blogs_record_comment_post_types', 'bbg_record_video_post_type_comments' );doing it this way, everything works except my custom comment action.
February 22, 2017 at 4:54 am #264030In reply to: Display activity of a specific group
danbp
ParticipantHi,
you have to use a group_id and to ensure you’re in an appropriate loop (activity or group)
To get a group id, you can for ex. do:
// check for a group ID if( bp_has_groups() ) { // Grab current group ID bp_the_group(); $group_id = bp_get_group_ID(); } // apply our changes only to this group ID's // conditionnal action if ( $group_id == 22 OR $group_id == 8 ) {… and so on!
You may also use bp_parse_args, depending where you use your custom work. In other words, you can create a complete new activity loop on a distinct page template for only one group.
February 16, 2017 at 10:54 pm #263856In reply to: Some questions regarding buddypress
r-a-y
Keymaster- Site Tracking – The description on the Settings page says it all – “Record activity for new posts and comments from your site.“. This is useful if the Activity Streams component is also active.
- Login Widget – Not sure why you want extra tabs for a login widget… if you need extra functionality, you can always add your own widget if you have some coding ability.
- Profile photo by URL or user-selectable profile photo – This isn’t a core option. Would have to be a custom plugin for now.
- Mini-blog – No core option, unless a user’s activity stream is enough. There are plugins out there like BuddyBlog that offer some frontend blogging functionality.
- Disabling emails – I think putting the desired email in draft mode might be sufficient to disable email sending. Test and see what happens!
February 8, 2017 at 12:06 pm #263616In reply to: add subnav to activity
kalughodakiya
ParticipantJust add sub nav using bp_core_new_subnav_item and modify file activity.php just put your code before if ( is_user_logged_in() && bp_is_my_profile() && ( !bp_current_action() || bp_is_current_action( ‘just-me’ ) ) )
bp_get_template_part( ‘activity/post-form’ );with if condition like
if(is_user_logged_in() && bp_is_my_profile() && bp_is_current_action( ‘schedule_message’ )){
get_template_part( ‘custom_files/schedule_message’ );if current action is you tab slug then load you page template otherwise default
January 10, 2017 at 2:00 pm #262699In reply to: how display content in submenu?
luisa227
ParticipantSimple. I want to make functional code
My actual code is:
function bpfr_custom_profile_sub_nav() { global $bp; $parent_slug = 'activity'; //Add subnav item bp_core_new_subnav_item( array( 'name' => __( 'Swap' ), 'slug' => 'swap', 'parent_url' => $bp->displayed_user->domain . $parent_slug.'/', 'parent_slug' => $parent_slug, 'screen_function' => 'swapluisa', 'position' => 1, ) ); } add_action( 'bp_setup_nav', 'bpfr_custom_profile_sub_nav' ); function swapluisa() { add_action( 'bp_template_title', 'my_groups_page_function_to_show_screen_title' ); add_action( 'bp_template_content', 'my_groups_page_function_to_show_screen_content' ); } add_action( 'bp_setup_nav', 'my_bp_nav_adder', 50 ); function my_groups_page_function_to_show_screen_content() { return bp_get_template_part('members/single/swap'); // (OR THIS???) return bp_get_template_part('wp-content/themes/betheme-child/buddypress/members/single'); } function my_groups_page_function_to_show_screen_title() { echo 'My new Page Title'; } function luisa_register_template_location() { return 'members/single/'; // (OR THIS????) return 'members/single/';wp-content/themes/betheme-child/buddypress/members/single' } function luisa_template_start() { if( function_exists( 'bp_register_template_stack' ) ) bp_register_template_stack( 'luisa_register_template_location' ); } add_action( 'bp_init', 'luisa_template_start' );but dont’work!
I repeat, surely accidentally pointing to the folder, I can not figure out the exact solution. when i write “OR THIS??” i try but don’t work.
where am I wrong? thanks
January 9, 2017 at 8:33 pm #262676In reply to: how display content in submenu?
luisa227
Participantsorry ๐ i don’t know!!!
I seem to do correctly, but does not work.
I also for testing entered my files everywhere, but does not find it anywhere !!!In my web-site the URL is
http://mysite.it/membri/testmember1/activity/swap/but it says “We are sorry, but the page you are looking for does not exist.”I have my swap.php (into there’s only a echo command)’s file in
wp-content/themes/child-theme/buddypress/members/single/
and inbp-custom.php(that is in my plugin folder) I writefunction my_groups_page_function_to_show_screen_content() { bp_get_template_part('members/single/swap'); } function luisa_register_template_location() { return 'wp-content/themes/betheme-child/buddypress/members/single'; }I try also to put the swap.php file into
wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/members/singlebut nothing is happen.where am I wrong? thanks
January 8, 2017 at 11:51 pm #262639In reply to: BuddyPress Enhancements and Tweaks
djsteveb
Participantdisclaimer, I am not a bp dev, just a long time user, and my knowledge is far from complete.
1 -each Profile / Member offered a separate gallery or media library?
This was a problem from the very beginning, and perhaps the biggest problem for bp aside from lousy filter options for the activity stream. Initially it was handled by the ‘bp-album’ plugin – which was later abandoned amidst some drama – rtmedia is kind of the standard for handling this now – but it’s bloated, important functions have gotten expensive, and it’s not well supported in core or themes – it’s terrible at keeping things separated like comments on media and galleries –
There is a new bp media like experimental thing that looks promising, and some attempts at making placeholders for bp media have been made in the past year, new hooks for bp attachment, etc. Some code has appeared on github showing a great start at possible core bp media handling – but not enough devs on that.if you must have media with bp I suggest getting the premium “press permit core” and ask for support in limiting what other users can see in the media library. God forbid you have a problem with users trolling other users – and you have media – as you can purchase the buddyblock plugin which will prevent most abuse user to user, but it does not hook into the separate commenting system that rt-media creates. I strongly encourage you to try the other media plugin and hope that works for what you need before getting stuck with rtmedia and no way to export it’s data to something else.
2 a cap on how many Mbโs a user is allowed to upload for the total amount of media space
Wordpress has a setting for this when using multi-site setup – but I think it affects only what gets posted to the user blogs aka sites. I think rtmedia has an optional purchase-able plugin for this if you use their system to allow for the media uploads – not sure if the other competing system has such functionality.This is a problem, and a solution should include a way for admins to look at users who have uploaded media, not just by user and space taken up, but also by date. There should be more control for deleting content with various parameters as well. I pity you if you find one day a user has uploaded 100s of photos that violate… terms.. and you have to delete each one at a time. If you find a way to handle this better with rtmedia I’d love for you to share it.
Currently I have tons of photos and videos that users have uploaded and no good way to look at or remove, aside from going profile to profile and manually checking what shows up there. A better way may exist, I have not found it yet.
3 – Why do all members have to be Authors in order to be able to Post because this was the only method that worked for me.
When you say post, that sounds like posting a post to a blog – either their own multi-site blog, or perhaps to a group blog. This is how worpdress is and is great for controlling things with blogs. If you mean a user needs to be an author in order to add to thier “activity stream” aka wall or profile or whatever, I do not think they need to be a blog author in order to do so… “What’s new” activity posts work fine without being a blog author.4 – BuddyPress and BB Press how should I set up my .htaccess file – this should be documented somewhere around here. Wish I could tell you, I don’t have any bb press running with any buddypress installs any longer.
If you don’t want robots to crawl your site, search for forums for making buddypress private – you’ll want to lock down your site with a password required to view anything – if you really want to block bots.. if it’s just the nicer bots you are referring to, like googlebot, yahoo and bigbots – then you can setup a robots.txt with something like
robots *
disallow /
allow index.phpbut I don’t think having the main engines index your index.php is really helpful with most WP themes.. you’d probably be better with “allow /about-us/” for example.. as most wp sites I’ve worked with dont have a good ol’ index.html
your experiences may vary..
With BP you eaither have lots of time to code, or you take everything as is for the most part. Auttomatic has not funded bp well since the first dev Andy left – it’s basically abandoned like unwanted bastard child that gets (almost) no support – and has been for years. Instead depending mainly on volunteer contributors that obviously have to do other things like earn a living and pay bills.
Some great people do amazing things making bp better – I appreciate those that are making the documentation better and fighting the good fight of dealing with all the wp core changes and how they affect bp when it updates – and other work to make it better. However what is seemingly most important to many webmasters and end users may not be on the roadmap for future releases – and finding developers to mod up BP is not as easy as one may hope either.
custom fixes today may well be broken with future updates, and no one has thought about the laws in Europe for privacy and users being able to export data you have them.. all kinds of things..
consider bp a huge mix of free code that is very experimental, and in my humble opinion should be removed from the wp plugin repo if automattic is not going to fund it properly – it certainly should not be on the first page view of plugins – anyone installing it likely has no idea what can of worms they are getting into.
If you are thinking of the future and how you may need to moderate user’s uploads and such, I strongly encourage you to test out the mediapress alternative – but realize in order to get core functionality with bp right now you will have to add on a walled garden from one place or another.. without any import / export options – before you invest too much of your time and your user’s pictures and videos into silos you may never escape, you right as well look into and test out peepso (https://www.peepso.com )- as they seem to have more skin in the game and have made at least some import / export things if I remember correctly.
again, I am not a bp dev. also I have not used mediapress yet – although I would with a fresh install – rtmedia has not met my expectations, although not a total fail, it is only 60% of what it should be. I have not used peepso yet either. Just a guy that’s been running a few bp installs for a few years, and my knowledge is fuzzy at best. surely @ma.tt, others thoughts, and your mileage may vary.
November 27, 2016 at 9:42 am #261369In reply to: Facebook plugin
Venutius
ModeratorI’m not sure about integrating fb into the activity feed but you can display the FB page activity in a widget with Custom Facebook Feed, also there are a couple of Social Login plugins to allow FB users to log in to your site using their fb credentials.
November 13, 2016 at 1:47 pm #260968In reply to: help with default activity stream tab
danbp
ParticipantYou’re talking about 2 different things: profile and groups. Let me explain you a little…
On the buddy nav bar, navigation looks similar but doesn’t work the same way on profile and on group page. While profile navigation use nav and sub-nav, the group navigation use only sub-nav.
Also, as documented on codex,
define('BP_DEFAULT_COMPONENT', '...' );is a constant related to a component, not a sub-nav tab. It let you define the default landing component, but not the one or other sub-nav tab. For example on profiles, the component Activity has 4 sub-nav attached to it: personnal, mentions, favorites, friends, groupsTo get one of them, you need to specify a new default tab, not another component. ๐
Buddybar main nav items on profile page
Activity Profile Friends Groups Forums (if you use group forums)Default tab is Activity/personnal. To change it for “Friends” you use the constant:
define('BP_DEFAULT_COMPONENT', 'friends' );To change the default landing tab from (Component/sub-tab). For example Activity/personnal to Activity/mentions, you define a new nav default tab with a function like this one:
function bpex_set_member_default_nav() { bp_core_new_nav_default ( array( 'parent_slug' => buddypress()->activity->id, // other "activity" sub_nav slugs : personal favorites friends groups 'subnav_slug' => 'mentions', 'screen_function' => 'bp_activity_screen_mentions' ) ); } add_action( 'bp_setup_nav', 'bpex_set_member_default_nav', 20 );For groups, it’s a similar technique, but a different syntax. The following example is a bit sophisticated, as it let you change the landing tab differently for each defined group.
Depending each group activity or target, you can choose a different default tab.
In this example, the kill bill group has Forum as landing tab, while Leon’s group use the group member directory.function bpex_custom_group_default_tab( $default_tab ){ /** * class_exists() is recommanded to avoid problems during updates * or when Groups Component is deactivated */ if ( class_exists( 'BP_Group_Extension' ) ) : $group = groups_get_current_group();//get the current group if( empty( $group ) ) { return $default_tab; } switch($group->slug){ case 'kill-bill': // group name (use slug format) $default_tab='forum'; break; case 'leon': $default_tab='members'; break; default: $default_tab='home';// the default landing tab break; } return $default_tab; endif; // end if ( class_exists( 'BP_Group_Extension' ) ) } add_filter('bp_groups_default_extension','bpex_custom_group_default_tab');All this tested and working with BP 2.7.2 / Twenty Sixteen
November 13, 2016 at 2:58 am #260962In reply to: help with default activity stream tab
Masoud
Participanthi @danbp
and many thanks for your answer.i’ve read the docs already. but i read them again as you said.
according to the docs, you can
//Change the default tab opened when looking at a group (default is home): define( 'BP_GROUPS_DEFAULT_EXTENSION', 'members' );but i want to Change the default tab opened when looking at a Activity (default is Personal):
so i put some codes (in bp-custom), to override :
—-
i’ve tried this (in bp-custom):
<?php define( 'BP_ACTIVITY_DEFAULT_EXTENSION', 'mentions' ); ?>
but i got 500 internal error.
—-
i’ve also tried this one (in bp-custom):<?php if ( !defined( 'BP_DEFAULT_COMPONENT' ) ) { if ( bp_is_active( 'activity' ) && isset( $bp->pages->activity ) ) $bp->default_component = 'mentions' ; } ?>but i got error 500 internal again.
—-
and i’ve tried this one too (in bp-custom):function change_activity_default_tab() { global $bp; set[$bp->activity(current_action)]->mentions }and 500 internal error again.
—-as i’ve read in the docs before, and i realized that it might be possible to change the Activity default extension too. (activity default tab is Personal (when you browse the prof , or click on switch from another tab to activity tab (when you click on activity tab) ) )
so i came here for detail and get more help to solve it.
i’d be grateful if you help me with this one too.
thanks for your time and help.
November 10, 2016 at 6:14 am #260892Topic: help with default activity stream tab
in forum How-to & TroubleshootingMasoud
Participanthi.
i am using latest versions of both wordpress and buddypress.and working on a food website.
in this website , i wanted to allow only authors to post activity updates .
(because it will be much easier for users to track their favorite chef recipes in the activity page.)
so i’ve hide the ” personal ” submenu of activity tab : Activity > Personal (where people can post updates)
with the help of following code in bp-custom.php :function bpfr_hide_tabs() { global $bp; if ( bp_is_user() && ( !current_user_can(author) || !current_user_can(administrator) ) ) { bp_core_remove_subnav_item($bp->activity->slug, 'just-me'); } } add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );but now when i go to my profile (as a subscriber)
i will see a 404 page.
i’ve searched a lot and i noticed that , now that i’ve removed the default activity stream tab , i have to point it to another tab. so when a user profile is loading (or if a user clicks on activity tab),
instead of default activity> personal . it load activity > mentions / OR / favorites / OR / … (some other submenu than personal )so my question is:
how can i change the default activity stream tab
from
Activity > Personal
To
Activity > Mentions – Or to – Activity > Favorites – …thanks a lot for any help.
November 4, 2016 at 4:52 pm #260732MatrixMedia
Participantsorry, I have not explained well, the second point, I Repeat:
I also tried to customize the Post Types default โpostโ, following this guide: https://codex.buddypress.org/plugindev/post-types-activities/
this is my function:
add_post_type_support( 'post', 'buddypress-activity' ); function customize_page_tracking_args() { // Check if the Activity component is active before using it. if ( ! bp_is_active( 'activity' ) ) { return; } bp_activity_set_post_type_tracking_args( 'post', array( 'component_id' => buddypress()->blogs->id, 'action_id' => 'new_blog_post', // or 'new_post' 'bp_activity_admin_filter' => __( 'Published a new post', 'emt-buddypress' ), 'bp_activity_front_filter' => __( 'Posts', 'emt-buddypress' ), 'contexts' => array( 'activity', 'member' ), 'activity_comment' => true, 'bp_activity_new_post' => __( '%1$s shared a new <a href="%2$s">post</a>', 'emt-textbuddypress' ), 'bp_activity_new_post_ms' => __( '%1$s sahred a new <a href="%2$s">post</a>, on the site %3$s', 'emt-textbuddypress' ), 'position' => 100, ) ); } add_action( 'bp_init', 'customize_page_tracking_args' );but when I publish a post on activity stream, is not displayed. If I remove the function or use a new custom_post_type, in this function, it works.
October 16, 2016 at 9:33 pm #259891In reply to: Please, Help Me!
Venutius
ModeratorIf you go to Customize>>menus you will see there are buddyPress pages there you can add to menus, but these are the user specific menu items i.e. My Activity etc. To add the global pages you just need to create a link to the page in question, i.e. http://www.yoursite.com/activity
October 6, 2016 at 5:42 pm #259541In reply to: [Resolved] Changing from a slug to a dynamic url
danbp
ParticipantOk, i misunderstood the whole… The initial question was:
what I am trying to link to is
http://localhost/wordpress/community/profile/<displayed_user>/Try this:
function tab_custom_link_to_page() { if ( bp_is_activity_component() || bp_is_page( BP_MEMBERS_SLUG ) ) { // link to what you want $link = bp_get_root_domain() . '/community/profile/'. bp_get_displayed_user_username(); echo '<li><a href="'. $link .'">Community</a></li>'; } } add_action( 'bp_member_options_nav', 'tab_custom_link_to_page' );September 23, 2016 at 5:47 am #259053bikerwp000
Participant<?php /** * Plugin Name: BP Loop Filters * Plugin URI: https://codex.buddypress.org/add-custom-filters-to-loops-and-enjoy-them-within-your-plugin * Description: Plugin example to illustrate loop filters * Version: 1.0 * Author: imath * Author URI: http://imathi.eu * License: GPL-2.0+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt */ // Exit if accessed directly if ( !defined( 'ABSPATH' ) ) exit; class BP_Loop_Filters { /** * Constructor */ public function __construct() { $this->setup_actions(); $this->setup_filters(); } /** * Actions * * @uses bp_is_active() * @uses is_multisite() */ private function setup_actions() { /** * Adds the random order to the select boxes of the Members, Groups and Blogs directory pages */ // Members component is core, so it will be available add_action( 'bp_members_directory_order_options', array( $this, 'random_order' ) ); // You need to check Groups component is available if ( bp_is_active( 'groups' ) ) { add_action( 'bp_groups_directory_order_options', array( $this, 'random_order' ) ); } // You need to check WordPress config and that Blogs Component is available if ( is_multisite() && bp_is_active( 'blogs' ) ) { add_action( 'bp_blogs_directory_order_options', array( $this, 'random_order' ) ); } /** * Registers the Activity actions so that they are available in the Activity Administration Screen */ // You need to check Activity component is available if ( bp_is_active( 'activity' ) ) { add_action( 'bp_register_activity_actions', array( $this, 'register_activity_actions' ) ); // Adds a new filter into the select boxes of the Activity directory page, // of group and member single items activity screens add_action( 'bp_activity_filter_options', array( $this, 'display_activity_actions' ) ); add_action( 'bp_member_activity_filter_options', array( $this, 'display_activity_actions' ) ); // You need to check Groups component is available if ( bp_is_active( 'groups' ) ) { add_action( 'bp_group_activity_filter_options', array( $this, 'display_activity_actions' ) ); } // You're going to output the favorite count after action buttons add_action( 'bp_activity_entry_meta', array( $this, 'display_favorite_count' ) ); } } /** * Displays a new option in the Members/Groups & Blogs directories * * @return string html output */ public function random_order() { ?> <option value="random"><?php _e( 'Random', 'buddypress' ); ?></option> <?php } /** * Registering the Activity actions for your component * * The registered actions will also be available in Administration * screens * * @uses bp_activity_set_action() * @uses is_admin() */ public function register_activity_actions() { /* arguments are : - 'component_id', 'component_action_type' to use in {$wpdb->prefix}bp_activity database - and 'caption' to display in the select boxes */ bp_activity_set_action( 'bp_plugin', 'bpplugin_action', __( 'BP Plugin Action' ) ); /* Activity Administration screen does not use bp_ajax_querystring Moreover This action type is reordering instead of filtering so you will only use it on front end */ if ( ! is_admin() ) { bp_activity_set_action( 'bp_plugin', 'activity_mostfavs', __( 'Most Favorited' ) ); } } /** * Building an array to loop in from our display function * * Using bp_activity_get_types() will list all registered activity actions * but you need to get the ones for your plugin, and this particular function * directly returns an array of key => value. As you need to filter activity * with your component id, the global buddypress()->activity->actions will be * more helpful. * * @uses buddypress() * @return array the list of your plugin actions. */ private function list_actions() { $bp_activity_actions = buddypress()->activity->actions; $bp_plugin_actions = array(); if ( !empty( $bp_activity_actions->bp_plugin ) ) { $bp_plugin_actions = array_values( (array) $bp_activity_actions->bp_plugin ); } return $bp_plugin_actions; } /** * Displays new actions into the Activity select boxes * to filter activities * - Activity Directory * - Single Group and Member activity screens * * @return string html output */ public function display_activity_actions() { $bp_plugin_actions = $this->list_actions(); if ( empty( $bp_plugin_actions ) ) { return; } foreach ( $bp_plugin_actions as $type ):?> <option value="<?php echo esc_attr( $type['key'] );?>"><?php echo esc_attr( $type['value'] ); ?></option> <?php endforeach; } /** * Displays a mention to inform about the number of time the activity * was favorited. * * @global BP_Activity_Template $activities_template * @return string html output */ public function display_favorite_count() { global $activities_template; // BuddyPress < 2.0 or filtering bp_use_legacy_activity_query if ( ! empty( $activities_template->activity->favorite_count ) ) { $fav_count = $activities_template->activity->favorite_count; } else { // This meta should already have been cached by BuddyPress :) $fav_count = (int) bp_activity_get_meta( bp_get_activity_id(), 'favorite_count' ); } if ( ! empty( $fav_count ) ): ?> <a name="favorite-<?php bp_activity_id();?>" class="button bp-primary-action">Favorited <span><?php printf( _n( 'once', '%s times', $fav_count ), $fav_count );?></span></a> <?php endif; } /** * Filters */ private function setup_filters() { add_filter( 'bp_ajax_querystring', array( $this, 'activity_querystring_filter' ), 12, 2 ); add_filter( 'bp_activity_get_user_join_filter', array( $this, 'order_by_most_favorited' ), 10, 6 ); add_filter( 'bp_activity_paged_activities_sql', array( $this, 'order_by_most_favorited'), 10, 2 ); // Maybe Fool Heartbeat Activities! add_filter( 'bp_before_activity_latest_args_parse_args', array( $this, 'maybe_fool_heartbeat' ), 10, 1 ); } /** * Builds an Activity Meta Query to retrieve the favorited activities * * @param string $query_string the front end arguments for the Activity loop * @param string $object the Component object * @uses wp_parse_args() * @uses bp_displayed_user_id() * @return array()|string $query_string new arguments or same if not needed */ public function activity_querystring_filter( $query_string = '', $object = '' ) { if ( $object != 'activity' ) { return $query_string; } // You can easily manipulate the query string // by transforming it into an array and merging // arguments with these default ones $args = wp_parse_args( $query_string, array( 'action' => false, 'type' => false, 'user_id' => false, 'page' => 1 ) ); /* most favorited */ if ( $args['action'] == 'activity_mostfavs' ) { unset( $args['action'], $args['type'] ); // on user's profile, shows the most favorited activities for displayed user if( bp_is_user() ) { $args['user_id'] = bp_displayed_user_id(); } // An activity meta query :) $args['meta_query'] = array( array( /* this is the meta_key you want to filter on */ 'key' => 'favorite_count', /* You need to get all values that are >= to 1 */ 'value' => 1, 'type' => 'numeric', 'compare' => '>=' ), ); $query_string = empty( $args ) ? $query_string : $args; } return apply_filters( 'bp_plugin_activity_querystring_filter', $query_string, $object ); } /** * Ninja Warrior trick to reorder the Activity Loop * regarding the activities favorite count * * @param string $sql the sql query that will be run * @param string $select_sql the select part of the query * @param string $from_sql the from part of the query * @param string $where_sql the where part of the query * @param string $sort the sort order (leaving it to DESC will be helpful!) * @param string $pag_sql the offset part of the query * @return string $sql the current or edited query */ public function order_by_most_favorited( $sql = '', $select_sql = '', $from_sql = '', $where_sql = '', $sort = '', $pag_sql = '' ) { if ( apply_filters( 'bp_use_legacy_activity_query', false ) ) { preg_match( '/\'favorite_count\' AND CAST\((.*) AS/', $where_sql, $match ); if ( ! empty( $match[1] ) ) { $new_order_by = 'ORDER BY '. $match[1] .' + 0'; $new_select_sql = $select_sql . ', '. $match[1] .' AS favorite_count'; $sql = str_replace( array( $select_sql, 'ORDER BY a.date_recorded' ), array( $new_select_sql, $new_order_by ), $sql ); } // $select_sql is carrying the requested argument since BuddyPress 2.0.0 } else { $r = $select_sql; if ( empty( $r['meta_query'] ) || ! is_array( $r['meta_query'] ) ) { return $sql; } else { $meta_query_keys = wp_list_pluck( $r['meta_query'], 'key' ); if ( ! in_array( 'favorite_count', $meta_query_keys ) ) { return $sql; } preg_match( '/\'favorite_count\' AND CAST\((.*) AS/', $sql, $match ); if ( ! empty( $match[1] ) ) { $sql = str_replace( 'ORDER BY a.date_recorded', 'ORDER BY '. $match[1] .' + 0', $sql ); } } } return $sql; } /** * Cannot pass the favorite data for now so just fool heartbeat activities */ public function maybe_fool_heartbeat( $r = array() ) { if ( empty( $r['meta_query'] ) ) { return $r; } $meta_query_keys = wp_list_pluck( $r['meta_query'], 'key' ); if ( ! in_array( 'favorite_count', $meta_query_keys ) ) { return $r; } else { $r['since'] = '3000-12-31 00:00:00'; } return $r; } } // 1, 2, 3 go ! function bp_loop_filters() { return new BP_Loop_Filters(); } add_action( 'bp_include', 'bp_loop_filters' );September 20, 2016 at 9:35 pm #258955In reply to: How to show full comment in the activity
danbp
ParticipantHi @tronix-ex,
Give this a try. Read more will only appear again if you use more than 500 000 characters…
Add to bp-custom.phpfunction bpfr_excerpt_length( $length ) { $length = 500000; // adjust the length to desired number of characters // Is the current page a user's activity stream page ? if( bp_is_user_activity() ) { return $length; } } add_filter( 'bp_excerpt_length', 'bpfr_excerpt_length', 11, 1 );September 19, 2016 at 2:38 pm #258911danbp
ParticipantHi @rezbiz,
in brief, you want to add some status dependent custom link to the BuddyBar.
I’ll ignore Kleo (premium theme) and Visual Composer (third party plugin).
Following examples let you add an external link to a non BP page on almost any menus (except BP usermenu).
How it works ?
– create a test page and call it Book.
– the page slug must be /book/
– the link (tab/button) will be displayed to logged-in users only.I made also a snippet which add such a link to the WordPress Main Menu. This menu is the one you see in WP’s menu customizer by default. Depending the theme you use, you have always a main menu and X others. This can vary and it’s to you to find how it can/should work eventually. See theme documentation and WP Codex if you get in trouble with it.
Note that it should work with all Twenty themes at least.Add the snippets to bp-custom.php and see the result. After that, read through the code and modify the page name/ID and slug to your need. Leave anything else untouched.
// add Custom tab on site wide activity and members directory pages function tab_custom_link_to_page() { if ( bp_is_activity_component() || bp_is_page( BP_MEMBERS_SLUG ) ) { if ( !is_user_logged_in() ) return false; // link to what you want $link = bp_get_root_domain() . '/book'; echo'<li><a href="'. $link .'">My Book</a></li>'; } } add_action( 'bp_activity_type_tabs', 'tab_custom_link_to_page' ); // site wide activity page add_action( 'bp_members_directory_member_types', 'tab_custom_link_to_page' ); // members directory page // add Custom tab on Profile Nav function add_profiles_link_to_page(){ if ( bp_is_profile_component() || bp_is_user() ) { if ( !is_user_logged_in() ) return false; $link = bp_get_root_domain() . '/book/'; ?> <li><a href="<?php echo $link; ?>"><?php printf( 'My Book' ); ?></a></li> <?php } } add_action( 'bp_member_options_nav', 'add_profiles_link_to_page' ); // add Custom tab on Groups Nav function add_groups_link_to_page(){ if( bp_is_active( 'groups' ) ) { if ( !is_user_logged_in() ) return false; $link = bp_get_root_domain() . '/'; bp_core_new_subnav_item( array( 'name' => 'My Book', 'slug' => 'book', 'parent_slug' => bp_get_current_group_slug(), 'parent_url' => $link, 'screen_function' => true, 'position' => 40 ) ); } } add_action( 'bp_setup_nav', 'add_groups_link_to_page' ); // add Custom tab on Groups Directory function add_groups_directory_link_to_page() { if( bp_is_active( 'groups' ) ) { if ( !is_user_logged_in() ) return false; if ( bp_is_current_action( 'custom' ) ) return; $link = bp_get_root_domain() . '/book'; $button_args = array( 'id' => 'my-books', 'component' => 'groups', 'link_text' => 'My Book', 'link_title' => 'My Book', 'link_class' => 'my-books no-ajax', 'link_href' => $link, 'wrapper' => false, 'block_self' => false, ); ?> <li><?php echo bp_get_button( apply_filters( 'bp_get_group_custom_button', $button_args ) ); ?></a></li> <?php } } add_action( 'bp_groups_directory_group_filter', 'add_groups_directory_link_to_page' ); // add Custom tab on WP Main Menu ( after Home, About, etc ) function main_menu_custom_link_to_page( $menu ) { if ( !is_user_logged_in() ) return $menu; else // link to what you want $link = bp_get_root_domain() . '/book'; $grouplink = '<li><a href="'. $link . '">My Book</a></li>'; $menu = $menu . $grouplink; return $menu; } add_filter( 'wp_nav_menu_items', 'main_menu_custom_link_to_page' );Yes, it looks complicated, but it isn’t. Simply it’s not homogeneous ! ๐
September 18, 2016 at 8:29 pm #258900danbp
ParticipantHere “the best guarded secret” finally revealed !
But it’s not a secret, is part of Codex and a multi handled topic subject on this forum.What we want to do: remove access possibility.
Where: on BuddyBar navigation menu (the one below the profile header).
Specifics: make the activity and forum tabs only visible to the logged in user.NOTE: The activity tab is shown by default when you visit a profile.
As we are going to hide/remove this tab to visitors, we need to define as first another default tab. If we won’t do that, the visitor will get a Page not found error. Which is not exactly the case here, the page exist but the visitor can’t access it.
Let’s define arbitrary Profile as the new default tab. You can of course define what ever other existing tab on your BuddyBar as default.
Add this line to bp-custom.php
define( 'BP_DEFAULT_COMPONENT','profile' );Now the mega “open secret” !
The folowing snippet contains almost any BP menu items you can have on a BuddyBar, and includes also the Forum item, in case you use bbPress.
You can remove or comment out those you don’t want to use.
Note also that it is only an example – you have to play with it to fit your need. But at least you have the right syntax to use.
Note also that some profile menu items are user only, such as message or notice. In other words, these are always private.This function goes preferably to bp-custom.php
function bpfr_hide_tabs() { global $bp; /** * class_exists() & bp_is_active are recommanded to avoid problems during updates * or when Component is deactivated */ if( class_exists( 'bbPress' ) || bp_is_active ( 'groups' ) ) : /** here we fix the conditions. * Are we on a profile page ? | is user site admin ? | is user logged in ? */ if ( bp_is_user() && !is_super_admin() && !is_user_logged_in() ) { /* and here we remove our stuff ! */ bp_core_remove_nav_item( 'activity' ); bp_core_remove_nav_item( 'friends' ); bp_core_remove_nav_item( 'groups' ); bp_core_remove_nav_item( 'forums' ); } endif; } add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );Some other hints for privacy
if you want to allow only the profile owner to view some tabs, replace
!is_user_logged_inby!bp_is_my_profile()– this scenario doesn’t need a check for logged in users as it is made bybp_is_my_profile.If you want only to make a profile private, read here.
If you want to remove a sub-nav item (ie. View on Profile), you use something like:
bp_core_remove_subnav_item( 'profile', 'view' );Many other possibilities for navigation are also available, including for groups. Several examples are given on Codex, here.
And if not enough, RTFM and search the forum ! ๐
Have fun !
-
AuthorSearch Results