Search Results for 'custom activity page'
-
AuthorSearch Results
-
November 10, 2016 at 6:14 am #260892
Topic: 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 !
September 17, 2016 at 6:32 pm #258866danbp
ParticipantHi,
not sure i understand correctly, but if you want the resume page to show as default landing tab (in place of the user activity) when you are on a profile, you can use this:
define( 'BP_DEFAULT_COMPONENT', 'resume' );Add it to bp-custom.php
Codex reference.
September 16, 2016 at 7:23 am #258782In reply to: How edit meta title for activity in bp-custom.php
inzerat
ParticipantThis is part of buddypress. On activity page have meta title description “Side wide Activy – Name of web” a i want change this in bp-custom.php
September 11, 2016 at 11:01 pm #258638danbp
ParticipantI’m unable to reproduce your issue on a single install with over 20 plugins active and plenty of custom functions active in bp-custom.php
I can upload medias without problem with different 3th party themes or Twenty’sTry to upload a fresh copy of WordPress and BP and see if it makes a difference.
Now about the snippet.
It works more or less, no code error. You commented the action, so it is deactivated if someone copy/paste it without correcting this.That said, what is the reason behind using a redirection to login if the site, or at least the buddyPress parts, should be private ?
Wouldn’t it be more logic to redirect visitors to an anonymous page with some important information, from which the first one could be Sorry, but this site is private ? Followed by some informations how to register or pay a fee or whatever the reason.
A private site has two type of visitors: those invited to join and the others. Don’t give the opportunity to those who are there by chance to enter the site so easily.
I let you think about this and eventually create an appropriate page and template.
Here a code example redirecting to a page called Intranet and the correct calls to slugs for all components (including bbPress).function bpfr_guest_redirect() { global $bp; // enter the slug or component conditional here if ( bp_is_activity_component() || bp_is_groups_component() || bp_is_blogs_component() || bp_is_page( BP_MEMBERS_SLUG ) || is_bbpress() ) { // not logged in user are redirected to - comment/uncomment or add/remove to your need if( !is_user_logged_in() ) { //wp_redirect( get_option('siteurl') ); //back to homepage //wp_redirect( get_option('siteurl') . '/register' ); // back to register page wp_redirect( get_option('siteurl') . '/intranet' ); // back to whatever page } } } add_filter( 'get_header', 'bpfr_guest_redirect', 1 );Add it to child-theme’s functions.php
September 9, 2016 at 6:17 pm #258589In reply to: Order by custom field in member loop
ositive
ParticipantI tryed to work also with this solution (provided by @shanebp too):
https://buddypress.org/support/topic/creating-a-new-order-by-filter-in-groups-loop-with-custom-sql/
but I do not obtain to order members by rating.. is this the right approach??function antares_members_filter_options() { echo '<option value="rating">rating</option>'; } add_action( 'bp_members_directory_order_options', 'antares_members_filter_options' ); function antares_ajax_querystring( $query_string, $object ) { if ( 'members' != $object ) return $query_string; if ( ! bp_is_members_directory() ) return $query_string; $query_args = wp_parse_args( $query_string, array() ); $page = $query_args['page']; if( isset( $query_args['action'] ) && $query_args['action'] == 'rating' ) { $query_args = array(); $query_args['page'] = $page; $query_args['orderby'] = 'rating'; $query_args['order'] = 'ASC'; $query_args['include'] = antares_get_members(); $query_string = http_build_query( $query_args ); } return $query_string; } add_filter( 'bp_ajax_querystring', 'antares_ajax_querystring', 32, 2 ); function antares_get_members() { global $wpdb; $sql = "SELECT a.ID as id, a.user_login AS name, a.display_name AS displayname, AVG(star) AS rating, COUNT(star) AS reviews FROM {$wpdb->prefix}users AS a LEFT JOIN {$wpdb->prefix}bp_activity AS b ON a.ID = b.usercheck WHERE (b.is_activated is null or b.is_activated=1) GROUP BY id ORDER BY rating DESC"; $buff = array(); $result = $wpdb->get_results( $sql , OBJECT ); foreach ($result as $row) { $buff[]= $row->id ; } $query_str= implode (',', $buff); return $query_str; }September 9, 2016 at 10:22 am #258559In reply to: removing DELETE from activity stream
jbboro3
ParticipantWhy don’t you just put this two lines of css code in your theme’s css or custom css page instead of trying to get into functions files..
a.button.item-button.bp-secondary-action.delete-activity.confirm {
display: none;
}
a.delete.acomment-delete.confirm.bp-secondary-action {
display: none;
}August 30, 2016 at 2:07 pm #258189In reply to: tinymce in activity replies and comments
jbboro3
ParticipantHey, @danbp Thanks for the long and detailed response.
I’m fully aware of what you’re trying to convey the risk factors on this.. But as my requirements are different, I’ve completely disabled the media library and allowed access the users to each individual gallery only (negating the access of other’s files).. I’ve uploaded images hosted on sub-domains that completely separate from the main site.
All the activities that takes place on the site are on the front end.. The back end wp administrator dashboard are disabled for editing ( of course they are enabled for updating plugins & adding pages occasionally) as most of the pages are done in custom-template.. No admin or author level privileges are created on the site – just the subscriber as it’s mainly a networking site.. The idea that attaching the media button gives lots of flexibility to the users to resize the images or review them in the content area itself before they can post the activity.. Unless it’s a forums or community sites, for a networking sites, leaving alone with html codes or text editors may be (perhaps) discouraging impression for the social users.
I’m glad that you pointed out it’s more of a wordpress thing than buddypress.. I’ll have a look at the possibility of getting it work and let you know.
Thanks.
August 27, 2016 at 6:43 pm #258125In reply to: tinymce in activity replies and comments
danbp
ParticipantThe ultimate tutorial to add wp_editor to What’s New textarea (on Site, Members and Group Activities pages).
Warning
The What’s New feature was never intended to publish posts or formatted text. It was imagined for brief announcement or instant conversation. That’s why this textarea is texturized and doesn’t allow much HTML tags. It is also ajaxified and need the original BP ID to work.
You will use it at your own risk.The following trick will let you remove the existing textarea from the template and replace it with a custom wp_editor. And it will be very customized ! For example, you will not have the visual tab, but only his HTML version, similar to the one you see on this forum for example.
Required:
BuddyPress activated
a working child theme
some understanding of HTML and php grammarThis trick was succesfully tested on a single install with WP 4.6, BP 2.6.2 and a Twenty Sixteen child theme.
Start !
Read from here how to remove the textarea in post-form.phpThe code to remove is line 40 and looks like this:
<textarea class="bp-suggestions" name="whats-new" id="whats-new" cols="50" rows="10" <?php if ( bp_is_group() ) : ?>data-suggestions-group-id="<?php echo esc_attr( (int) bp_get_current_group_id() ); ?>" <?php endif; ?> ><?php if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_textarea( $_GET['r'] ); ?> <?php endif; ?></textarea>You replace it by:
<?php $content = ''; $editor_id = 'whats-new'; wp_editor( $content, $editor_id ); ?>As the visual edit tab doesn’t work, you must deactivate it. In your child-theme functions.php, add this:
add_filter( 'user_can_richedit' , '__return_false', 50 );And that’s it !
If you want also rich edit for activity comments, which i didn’t recommand for sites who have many comments, you can use the same technique as above, with some more settings. Note that each comment has is own ID and that each comment editor should also have an unique ID.
First, you need to remove the textarea from (child-theme/buddypress/)activity/entry.php
You remove this:
<textarea id="ac-input-<?php bp_activity_id(); ?>" class="ac-input bp-suggestions" name="ac_input_<?php bp_activity_id(); ?>"></textarea>
and replace it by<?php $id = bp_get_activity_id(); $content = ''; $editor_id = 'ac-input-'. $id; $settings = array( 'textarea_name' => 'ac_input_'. $id, 'editor_class' => 'ac-input bp-suggestions' ); wp_editor( $content, $editor_id, $settings ); ?>With Twenty Sixteen, i first couldn’t see the Post Update button and the option selector. I got it with this little CSS adjustment (in child-theme/style.css).
div#whats-new-options { display: block!important;}Function reference: wp_editor.
August 20, 2016 at 6:22 am #257815alexdex
ParticipantHi, i put this:
define ( ‘BP_ENABLE_ROOT_PROFILES’, true );
add_filter( ‘bp_core_enable_root_profiles’, ‘__return_true’ );
I try in bp-custom. php and also in my function theme but not work
Every time i click in the activity page on the username (like email) do not work, 404 error
For example, if a username member is alex7@gmail.com and i click do not work, if is only alex7 it work perfect
The path is:
members/alex7@gmail.com/ DO NOT WORK
members/alex7/ WORK
Can you help me?
Thanks a lot
August 16, 2016 at 10:19 am #257677Apokh
Participant– checked- theres only one Activity page
– resaved permalink structure
– i dont use custom code, but activity+ plugin
– i use quiet a bunch of additional plugins:
–BoweCodes
–Buddypress
–DisableFeeds
–DownloadManager
–DynamicWidgets
–EventsManager
–GoogleAnalyticsDashboard
–GoogleFonts for WP
–HungryFEED
–LayerSliderWP
–Mediapress
–Members
–Metaslider+Pro
–myCred
–myCredHookBP
–PageBuilder Siteorigin
–PaypalDonations
–Peters Login Redirect
–PHP Text Widget
–SimplePress
–Siteorigins Masonry
–SpamProtect by Cleantalk
–TablePress
–Wordpress VideoGalery
–WP FullCalendar
–WP Lastlogin
–WP TwitterFeeds
–WP ULike
–WP touchmobileAugust 16, 2016 at 8:02 am #257648danbp
Participant@apock i merged your older topic to this one.
– ensure you have only one activity page (and none in trash).
– resave your permalinks. Sometimes pages are lost after updates.
Also:
– have you tested with another theme ?
– which plugins do you use ?
– do you use some custom code related to activities ?July 26, 2016 at 11:17 pm #257046In reply to: Custom Posts in Activity Stream.
bigkahunaburger
ParticipantTry this (the second function adds the course title):
function customize_page_tracking_args() { if ( ! bp_is_active( 'activity' ) ) { return; } add_post_type_support( 'sfwd-courses', 'buddypress-activity' ); bp_activity_set_post_type_tracking_args( 'sfwd-courses', array( 'action_id' => 'new_sfwd-courses', 'bp_activity_admin_filter' => __( 'Published a new course', 'custom-textdomain' ), 'bp_activity_front_filter' => __( 'Course', 'custom-textdomain' ), 'bp_activity_new_post' => __( '%1$s wrote a new course, <a href="%2$s">[Course]</a>', 'custom-textdomain' ), 'bp_activity_new_post_ms' => __( '%1$s wrote a new course, <a href="%2$s">[Course]</a>, on the site %3$s', 'custom-textdomain' ), 'contexts' => array( 'activity', 'member' ), 'comment_action_id' => 'new_sfwd-courses_comment', 'bp_activity_comments_admin_filter' => __( 'Commented on a course', 'custom-textdomain' ), 'bp_activity_comments_front_filter' => __( 'Course Comments', 'custom-textdomain' ), 'bp_activity_new_comment' => __( '%1$s commented on a <a href="%2$s">Course</a>', 'custom-textdomain' ), 'bp_activity_new_comment_ms' => __( '%1$s commented on a <a href="%2$s">Course</a>, on the site %3$s', 'custom-textdomain' ), 'position' => 100, ) ); } add_action( 'init', 'customize_page_tracking_args', 1000 ); function new_sfwd-courses_include_post_type_title( $action, $activity ) { if ( empty( $activity->id ) ) { return $action; } if ( 'new_sfwd-courses' != $activity->type ) { return $action; } preg_match_all( '/<a.*?>([^>]*)<\/a>/', $action, $matches ); if ( empty( $matches[1][1] ) || '[Course]' != $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', 'new_sfwd-courses_include_post_type_title', 10, 2 );July 19, 2016 at 11:34 pm #256818In reply to: Incorrect all member number count
knowitallnz
ParticipantHi Jrzvw,
Were you able to fix this?
I can’t find where to start a new questions so i will just add to this one?
My current site only shows the members that were active. There is 50 WP members registered but only 22 showing on ALL MEMBERS page. I feel the amount of members showing will influence the amount that will join up. SO this one time I would like to have it show all registered members and after it can just add them as they are active.
I tried :
add_filter( ‘bp_get_total_member_count’, ‘bp_core_get_total_member_count’ );in the theme function.php and also bp-custom.php BUT it did nothing.I tried a few other suggestions e.g one that did make the last activity of all users registered to be a certain time, however this made all the Members look as they are logged in. Is there any code I can insert in function.php that will show the members registered and not just the active ones?
Cheers.
BP 2.6.11
WP 4.5.3July 19, 2016 at 11:11 pm #256817buddycore
ParticipantIf you look at wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/activity/index.php That’s the template you need to edit in order to change that text.Inside
wp-content/themes/your-theme/Make a file calledbuddypress.php. In that file add the following…<?php get_header(); ?> <?php the_post(); the_content(); ?> <?php get_footer(); ?>By default BuddyPress will use a file located in your theme that currently exists, something like
page.phpas you can read about here.By creating a
buddypress.phpwe’re telling BuddyPress to use a custom template loader for all BuddyPress pages and components. Inside that file (buddypress.php) you can do anything you like for the “wrapper” around your BuddyPress stuff. In the code example above forbuddypress.phpwe’re grabbing the content but not bringing in things like<?php the_title(); ?>like you will find in a typicalpage.phpthat most WordPress themes will have.This will remove ALL page titles from BuddyPress pages, as you now have a custom “wrapper” for those areas the plugin will use.
If you wish to remove the title on a per page basis you may simply want to do a CSS solution and do target the
bodytag with CSS and then any suitable elements in the HTML. This means you could do something like…body.activity.directory div.page-inner h2 { display: none; }If you don’t want to do a CSS solution you can then look into component detection.
Hope that helps.
July 15, 2016 at 4:08 am #256620In reply to: Is filtering Activity on CPT meta info possible?
Ben Riga
ParticipantDan,
I spent some time on this and have figured out the loop that will give me the activity entries I need. I’m trying to add the list of activities on the same page I display the Beer custom post type. So show the beer info at the top and the list of related activities below it. I’m doing that on a theme page and would need to call the activity/entry.php for each of the entries. Is there a way to do that or would I need to copy the code from there?
The query will look something like this:
$args = array( 'post_type' => 'check_in', 'posts_per_page' => '-1', 'post_status' => array( 'publish', ), 'meta_key' => 'check_in_details_beer-id', 'meta_value' => $current_post ); // run the query $query_checkins = new WP_query ( $args ); // check the query returns posts if ( $query_checkins->have_posts() ) : while ( $query_checkins->have_posts() ) : $query_checkins->the_post(); $ci_postid = get_the_ID(); if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . '&secondary_id='. $ci_postid ) ) :Thanks for the help and support,
BenJuly 11, 2016 at 6:02 pm #256490In reply to: How to hide profile menu items from other users
danbp
ParticipantThe Home tab is the default one. If you remove that tab, BP has no way to know where to output the other group tabs content. If you remove Home(aka activity) you should define another landing tab.
But when you want to modify groups, you shouldn’t define ‘profile’, but ‘groups’. (read what you wrote!)
For the profile landing tab, see this codex page.For groups, you can try this snippet. This let you define a different landing tab for each of your groups (not profile, ok ?). 😉
function bpfr_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 'groupe-2014': $default_tab='members'; break; default: $default_tab='home';// the original default landing tab break; } return $default_tab; endif; // end if ( class_exists( 'BP_Group_Extension' ) ) } add_filter('bp_groups_default_extension','bpfr_custom_group_default_tab');July 6, 2016 at 10:41 am #256029In reply to: Top posts on front page
sharmavishal
Participantdont think there is a ready plugin for this..there is a plugin by imath which offers sticky activity …but that has to be done manually by the admin…maybe in future we can have custom activity pages like groups/members have right now
July 3, 2016 at 11:45 pm #255676In reply to: auto-refresh “load newest” not working
danbp
ParticipantHi,
tested the theme – Load More is working on all activity pages. Unable to reproduce.
Deactivate all plugins except BP.
If you use custom functions (in child or bp-custom), remove them and test again.Check also your custom CSS. Sometimes, renaming an element make JS unable to find the load more button.
-
AuthorSearch Results