Olaf posted on 2008-05-19 20:25:18 #
After getting more and more users for this bbpress forum I got problems posting new topics/posts. While checking the bbpress forum I found this thread:
http://bbpress.org/forums/topic/error-after-new-post-all-of-a-sudden
The user here describes exactly the same problem. After some debugging I found the problems source: The plugin selects all user and tests than if a user has the topic in his favorites. Executing the plugin takes a lot of time after several thousands of registered users.
I changed the function notification_select_all_users to:
function notification_select_all_users($post_id) {
global $bbdb;
$all_users = $bbdb->get_results("
SELECT u.ID, u.user_email
FROM $bbdb->users AS u, $bbdb->usermeta AS um
WHERE u.ID = um.user_id
AND um.meta_key = 'favorites'
AND $post_id IN (um.meta_value)
AND u.user_status = 0");
return $all_users;
}
Next we need to change the function notification_new_post a little bit (also changed the coding style a little):
function notification_new_post() {
global $bbdb, $bb_table_prefix, $topic_id, $bb_current_user;
$all_users = notification_select_all_users($topic_id); // add $topic_id
if (!empty($all_users)) { // test if user array is not empty
foreach ($all_users as $userdata) {
if ( notification_is_activated( $userdata->ID ) ) {
if ( is_user_favorite( $userdata->ID, $topic_id ) ) {
$topic = get_topic($topic_id);
$message = __("There is a new post on: %1\$s \nReply by: %2\$s \n\n%3\$s ");
mail( $userdata->user_email, bb_get_option('name') . ':' . __('Notification'),
sprintf( $message, $topic->topic_title, get_user_name($bb_current_user->ID), get_topic_link($topic_id) ),
'From: ' . bb_get_option('from_email')
);
}
}
}
}
}
This small modification will solve the problem and will produce a lower server load even for bbpress forum with only a few registered users.
The most popular forum posts:
Comments / discussions
Olaf posted on 2009-08-08 05:09:16 #
Looks like that the meta keyname has changed some time ago. The old name "favorites" is changed into "bb_favorites". You need to change the function notification_select_all_users to get this plugin working again:
function notification_select_all_users($post_id) {
global $bbdb;
$all_sql = "
SELECT u.ID, u.user_email
FROM $bbdb->users AS u, $bbdb->usermeta AS um
WHERE u.ID = um.user_id
AND um.meta_key = 'bb_favorites'
AND $post_id IN (um.meta_value)
AND u.user_status = 0";
$all_users = $bbdb->get_results($all_sql);
return $all_users;
}
Maybe I will release a new and better version soon...
devxiligroup posted on 2009-10-13 13:44:11 #
please find error when posting a new post in bbpress forum ???
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /forumdev/bbpress/my-plugins/mod-notification/moderator_notification.php on line 49
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /forumdev/bbpress/my-plugins/mod-notification/moderator_notification.php on line 49
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /forumdev/bbpress/my-plugins/mod-notification/moderator_notification.php on line 49
Warning: Cannot modify header information - headers already sent by (output started at /forumdev/bbpress/my-plugins/mod-notification/moderator_notification.php:49) in /forumdev/bbpress/bb-includes/functions.bb-pluggable.php on line 232
Used with latest BBpress 1.02
What do you think of that ?
Michel
Olaf posted on 2009-10-13 13:53:59 #
Hello,
do you use bbpress together with wordpress?
xArturox posted on 2010-05-13 10:51:15 #
hi, i've the same problem, when i go to a normal user profile i see
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /html/forums/my-plugins/mod-notification/moderator_notification.php on line 49
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /html/forums/my-plugins/mod-notification/moderator_notification.php on line 49
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /html/forums/my-plugins/mod-notification/moderator_notification.php on line 49
but all is ok for the admin and moderator.
is possible have a solution? thanks
i use bbpress 1.0.2
Olaf posted on 2010-05-13 10:54:31 #
Hi,
do you made this modification here?
xArturox posted on 2010-05-13 11:02:29 #
no, to add the modification i have to add the "function" to the file, but where? thanks
is possible have a complete updated version of your fantastic plugin? thanks ;)
Olaf posted on 2010-05-13 11:24:37 #
I see whats wrong here, this topic is about a fix for a 3rd party notification plugin written by Thomas Klaiber.
Your question is about a different plugin ;)
Please check the table value for the user within phpmyadmin:
table: bb_usermeta
column: meta_key = bb_capabilities
Tell me the value.
Note, I have never tested this plugin for bbpress+wordpress configurations
To keep this topic clean please open a new topic.