Search Results for 'code'
-
Search Results
-
Hi,
I have created a custom notification for my site when a post is published, the code used to do this is :-
// this is to add a fake component to BuddyPress. A registered component is needed to add notifications function custom_filter_notifications_get_registered_components( $component_names = array() ) { // Force $component_names to be an array if ( ! is_array( $component_names ) ) { $component_names = array(); } // Add 'custom' component to registered components array array_push( $component_names, 'publishpost' ); // Return component's with 'custom' appended return $component_names; } add_filter( 'bp_notifications_get_registered_components', 'custom_filter_notifications_get_registered_components' ); // this hooks to post creation and saves the post id function bp_custom_add_notification( $post_id, $post ) { $post = get_post( $post_id ); $author_id = $post->post_author; $blogusers = get_users( array( 'role' => 'staff' ) ); // Array of WP_User objects. foreach ( $blogusers as $user ) { bp_notifications_add_notification( array( 'user_id' => $user->id, 'item_id' => $post_id, 'component_name' => 'publishpost', 'component_action' => 'publishpost_action', 'date_notified' => bp_core_current_time(), 'is_new' => 1, ) ); } } add_action( 'publish_post', 'bp_custom_add_notification', 99, 2 ); /** * Format the BuddyBar/Toolbar notifications * * @since bbPress (r5155) * * @package bbPress * * @param string $action The kind of notification being rendered * @param int $item_id The primary item id * @param int $secondary_item_id The secondary item id * @param int $total_items The total number of messaging-related notifications waiting for the user * @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar */ function custom_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { // New custom notifications if ( 'publishpost_action' === $action ) { $post = get_post( $item_id ); $author_name = get_the_author_meta('display_name', $post->post_author); $custom_title = bp_core_get_user_displayname( $post->post_author ) . ' published a new post "' . get_the_title( $item_id ) . '"'; $custom_link = get_permalink( $post ); $custom_text = bp_core_get_user_displayname( $post->post_author ) . ' published a new post "' . get_the_title( $item_id ) . '"'; // WordPress Toolbar if ( 'string' === $format ) { $return = apply_filters( 'publishpost_filter', '<a href="' . esc_url( $custom_link ) . '" title="' . esc_attr( $custom_title ) . '">' . esc_html( $custom_text ) . '</a>', $custom_text, $custom_link ); // Deprecated BuddyBar } else { $return = apply_filters( 'publishpost_filter', array( 'text' => $custom_text, 'link' => $custom_link ), $custom_link, (int) $total_items, $custom_text, $custom_title ); } return $return; } if ( 'bbp_new_reply' === $action ) { $topic_id = bbp_get_reply_topic_id( $item_id ); $topic_title = bbp_get_topic_title( $topic_id ); $topic_link = wp_nonce_url( add_query_arg( array( 'action' => 'bbp_mark_read', 'topic_id' => $topic_id ), bbp_get_reply_url( $item_id ) ), 'bbp_mark_topic_' . $topic_id ); $title_attr = __( 'Topic Replies', 'bbpress' ); if ( (int) $total_items > 1 ) { $text = sprintf( __( 'You have %d new replies', 'bbpress' ), (int) $total_items ); $filter = 'bbp_multiple_new_subscription_notification'; } else { if ( !empty( $secondary_item_id ) ) { $text = sprintf( __( 'You have %d new reply to %2$s from %3$s', 'bbpress' ), (int) $total_items, $topic_title, bp_core_get_user_displayname( $secondary_item_id ) ); } else { $text = sprintf( __( 'You have %d new reply to %s', 'bbpress' ), (int) $total_items, $topic_title ); } $filter = 'bbp_single_new_subscription_notification'; } // WordPress Toolbar if ( 'string' === $format ) { $return = apply_filters( $filter, '<a href="' . esc_url( $topic_link ) . '" title="' . esc_attr( $title_attr ) . '">' . esc_html( $text ) . '</a>', (int) $total_items, $text, $topic_link ); // Deprecated BuddyBar } else { $return = apply_filters( $filter, array( 'text' => $text, 'link' => $topic_link ), $topic_link, (int) $total_items, $text, $topic_title ); } do_action( 'bbp_format_buddypress_notifications', $action, $item_id, $secondary_item_id, $total_items ); return $return; } } add_filter( 'bp_notifications_get_notifications_for_user', 'custom_format_buddypress_notifications', 1, 5 );How can i create the same for a new bbpress topic? i’m thinking i need to change this code section but not sure how
// this hooks to post creation and saves the post id function bp_custom_add_notification( $post_id, $post ) { $post = get_post( $post_id ); $author_id = $post->post_author; $blogusers = get_users( array( 'role' => 'staff' ) ); // Array of WP_User objects. foreach ( $blogusers as $user ) { bp_notifications_add_notification( array( 'user_id' => $user->id, 'item_id' => $post_id, 'component_name' => 'publishpost', 'component_action' => 'publishpost_action', 'date_notified' => bp_core_current_time(), 'is_new' => 1, ) ); } } add_action( 'publish_post', 'bp_custom_add_notification', 99, 2 );I am using woffice as the theme, bbpress version 2.5.14, buddypress version 4.1.0 and the latest version of wordpress
Thanks
Hi,
I have created a custom notification for my site when a post is published, if i have buddypress activated alone i see the notification text but as soon as i activate bbpress i can no longer see the notification description. In order to work out this was happening when bbpress was activated i created a whole new blank install of wpress and only installed the two plugins and when i deactivated bbpress it showed the text.
this is how the notification shows when bbpress is activated
https://www.dropbox.com/s/uepps9cjcd8xan5/With%20BbPress%20no%20text.PNG?dl=0this is how the notification shows when bbpress is NOT activated
https://www.dropbox.com/s/03wch6bc27nsked/Without%20BbPress%20showing%20text.PNG?dl=0I am using Twenty seventeen as the theme, bbpress version 2.5.14, buddypress version 4.1.0 and the latest version of wordpress
The code i have used to generate the notification is below, and this is located in \wp-content\plugins\bp-custom.php
<?php // this is to add a fake component to BuddyPress. A registered component is needed to add notifications function custom_filter_notifications_get_registered_components( $component_names = array() ) { // Force $component_names to be an array if ( ! is_array( $component_names ) ) { $component_names = array(); } // Add 'custom' component to registered components array array_push( $component_names, 'publishpost' ); // Return component's with 'custom' appended return $component_names; } add_filter( 'bp_notifications_get_registered_components', 'custom_filter_notifications_get_registered_components' ); // this hooks to post creation and saves the post id function bp_custom_add_notification( $post_id, $post ) { $post = get_post( $post_id ); $author_id = $post->post_author; bp_notifications_add_notification( array( 'user_id' => $author_id, 'item_id' => $post_id, 'component_name' => 'publishpost', 'component_action' => 'publishpost_action', 'date_notified' => bp_core_current_time(), 'is_new' => 1, ) ); } add_action( 'publish_post', 'bp_custom_add_notification', 99, 2 ); function custom_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { // New custom notifications if ( 'publishpost_action' === $action ) { $post = get_post( $item_id ); $custom_title = $post->post_author . ' published a new post ' . get_the_title( $item_id ); $custom_link = get_permalink( $post ); $custom_text = $post->post_author . ' published a new post ' . get_the_title( $item_id ); // WordPress Toolbar if ( 'string' === $format ) { $return = apply_filters( 'publishpost_filter', '<a href="' . esc_url( $custom_link ) . '" title="' . esc_attr( $custom_title ) . '">' . esc_html( $custom_text ) . '</a>', $custom_text, $custom_link ); // Deprecated BuddyBar } else { $return = apply_filters( 'publishpost_filter', array( 'text' => $custom_text, 'link' => $custom_link ), $custom_link, (int) $total_items, $custom_text, $custom_title ); } return $return; } } add_filter( 'bp_notifications_get_notifications_for_user', 'custom_format_buddypress_notifications', 10, 5 );I need to get it so that when bbpress is activated i can see the custom notification description as we use bbpress for our forums
Topic: Topic View
I have searched everywhere for an answer but cant find one to this
I have created a single page forum, using a custom page and a shortcode for forum id. The layout for this page is completely different to the rest of my site. All is good with that until you click on a topic and the topic page reverts back to the standard template of the rest of my site.
I need the single topic page to replicate that one custom page on my site and can’t for the life of me work out how. Would be good if I could just duplicate the page layout by creating a new page and using shortcode like I did with the forum page, but the only shortcode for topics I can find is [bbp-single-topic id=$topic_id] which calls for a specific topic id, not for all topics.
How do I get around this. Thanks in advance.
Topic: Undefined Index Notices
I’m receiving a couple undefined index notices whenever viewing the settings page:
PHP Notice: Undefined index: args in /wp-content/plugins/bbpress/includes/admin/admin.php on line 370 PHP Notice: Undefined index: sanitize_callback in /wp-content/plugins/bbpress/includes/admin/admin.php on line 374Any ideas what could be causing this?
hi.
I would like to know how to manage the form for creating a new topic.
With the plugin BBP Pack style, I have created a button “Create a new topic” and i would like that, once you click on that button, we can write our topic and publish it after.
For that, i already have created a dedicated page (https://blogfcombeta.wpengine.com/creer-un-nouveau-sujet/) with a bbcode.
What i want now is to redirect the create topic button on the dedicated page, and MUST important, to delete the current form displayed in the sub forum like this page : https://blogfcombeta.wpengine.com/forum-freelance/outils-freelance/outils-productivite-gestion-de-projet-freelance/Is It someone who know how to do that ?
Thanks.
PS : if you could also help me to well positionned the Subscribe button, it would be very pleasant !
The site is still private so for access it, please using this iD : blogfcombeta / e8556cb8Hi Folks
i have more forums but only need show the forums by groups created by Buddypress, this is my code, only apears One course, can somebody help me?
add_shortcode( 'DASH_forums', 'DASH_forums_func' ); function DASH_forums_func() { $group_ids = groups_get_user_groups(bp_loggedin_user_id()); foreach($group_ids["groups"] as $group_id) { $nombregrupo = groups_get_group(array( 'group_id' => $group_id )) -> name; $descripciongrupo = groups_get_group(array( 'group_id' => $group_id )) -> description; $html .= '<div id="enlacecurso"><a href="' . home_url() . '/groups/' . $nombregrupo . '/forum">' . $nombregrupo . ' Group Forum</a>' . (end($group_ids["groups"]) == $group_id ? '' : '' ) ; $html .= '</div>'; return $html; } }I have been troubleshooting an issue with embedded iframe table from datawrapper.de. The responsive iframe code was not changing height parameters on small screens so table was cut off. After disabling plugins I found that the problem went away after disabling bbpress.
datawrapper.de support told me this:
A part of the embed code contains the character string [b], it seems that your CMS automatically replaces this with an html strong tag, so the embed script no longer works.So I guess the replace [b] with an html strong tag is part of bbpress? Any way to turn that off in bbpress?
Hi, I want to display 3 latest topics with new replies for each forum category. In loop-single-forum.php file I created this:
$count = bbp_get_forum_topic_count(); $user = bbp_get_topic_author_id( bbp_get_forum_last_topic_id() ); if ( $count != 0 ) { echo '<a href="'. bbp_get_forum_last_topic_permalink().'"></a>'; // Link to the topic echo'<a href="'. bbp_get_user_profile_url( $user ) .'"><img class="avatar" src="'. bp_core_fetch_avatar ( array( 'item_id' => $user, 'type' => 'full', 'html' => false ) ).'" /></a>'; // Link to the topic author profile with author's avatar echo '<div class="title">'. bbp_get_forum_last_topic_title().'</div>'; // Title of the topic with last activity echo '<div class="activity">Last activity '. bbp_get_forum_last_active_time().'</div>'; // Time of the topic last activity } else { echo 'No topics'; // Information if there is no topics }How to display two more topics (if they exist)?