My first plugin for bbpress:
Moderator New Post Notification
Description:
Sends a notification e-mail to all moderators and admins if there is a new post from a regular member.
Enjoy and let me know what do you think.
» PHP Forum Archive » bbpress plugins and modifications
My first plugin for bbpress:
Moderator New Post Notification
Description:
Sends a notification e-mail to all moderators and admins if there is a new post from a regular member.
Enjoy and let me know what do you think.
The plugin is listed now on the bbpress website:
http://bbpress.org/plugins/topic/75?replies=1
don't forget to vote
I got this installed and I don't get any emails. New users are receiving their emails, but I don't get notifications when anyone posts.
What could be wrong?
Hi,
what is your role on your forum? do you tried a second (admin) account?
Hi, I have a stand alone installation of bbpress and when I use the plugin I get this error:
bbPress database error: [Table 'db164673748.bb_users' doesn't exist]
SELECT um.meta_value AS role FROM bb_users AS u, bb_usermeta AS um WHERE u.ID = um.user_id AND um.meta_key = 'bbpress_capabilities' AND u.user_status = 0 AND u.ID = 1
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /homepages/34/d21941373/htdocs/forum/my-plugins/moderator_notification.php on line 40
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /homepages/34/d21941373/htdocs/forum/my-plugins/moderator_notification.php on line 40
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /homepages/34/d21941373/htdocs/forum/my-plugins/moderator_notification.php on line 40
Warning: Invalid argument supplied for foreach() in /homepages/34/d21941373/htdocs/forum/my-plugins/moderator_notification.php on line 73
Warning: Cannot modify header information - headers already sent by (output started at /homepages/34/d21941373/htdocs/forum/bb-includes/db-mysql.php:130) in /homepages/34/d21941373/htdocs/forum/bb-includes/pluggable.php on line 228
I have read the suggestions, but I still habe no solution for this. Can you help me?
I guess you trapped into the table name bug :)
I guess your user table is not bb_user?
Well, you are right. My tables name was different.. I changed it, but now I have a different error:
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /homepages/34/d21941373/htdocs/forum/my-plugins/moderator_notification.php on line 40
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /homepages/34/d21941373/htdocs/forum/my-plugins/moderator_notification.php on line 40
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /homepages/34/d21941373/htdocs/forum/my-plugins/moderator_notification.php on line 40
Warning: Invalid argument supplied for foreach() in /homepages/34/d21941373/htdocs/forum/my-plugins/moderator_notification.php on line 73
Warning: Cannot modify header information - headers already sent by (output started at /homepages/34/d21941373/htdocs/forum/my-plugins/moderator_notification.php:40) in /homepages/34/d21941373/htdocs/forum/bb-includes/pluggable.php on line 228
first be sure that you have this query in your plugin.
(echo the sql statement, access the plugin file directly and test the output with phpmyadmin) I hope that I don't ask too much ;)
I am Sorry, I don't know how to test the plugin with phpmyadmin. I located the term "array_key_exists()" in \bb_includes\template-functions.php, upgrade-functions.php, profile-edit.php and gettext.php.
Look, I think you get this error because of an empty array, if you test the SQL statement you know the problem.
btw. I forgot to post the modified function:
function is_moderator($user_id) {
global $bbdb;
$mods = array('moderator', 'administrator', 'keymaster');
$is_mod = false;
$row = $bbdb->get_row("SELECT um.meta_value AS role
FROM $bbdb->users AS u, $bbdb->usermeta AS um
WHERE u.ID = um.user_id
AND um.meta_key = 'bb_capabilities'
AND u.user_status = 0
AND u.ID = $user_id
");
$arr = unserialize($row->role);
if (count($mods) > 0) {
foreach($mods as $val) {
if (array_key_exists($val, $arr)) {
$is_mod = true;
break;
}
}
}
return $is_mod;
}
Sorry, still the same:
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /homepages/34/d21941373/htdocs/forum2/my-plugins/moderator_notification.php on line 41
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /homepages/34/d21941373/htdocs/forum2/my-plugins/moderator_notification.php on line 41
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /homepages/34/d21941373/htdocs/forum2/my-plugins/moderator_notification.php on line 41
Warning: Invalid argument supplied for foreach() in /homepages/34/d21941373/htdocs/forum2/my-plugins/moderator_notification.php on line 76
Warning: Cannot modify header information - headers already sent by (output started at /homepages/34/d21941373/htdocs/forum2/my-plugins/moderator_notification.php:41) in /homepages/34/d21941373/htdocs/forum2/bb-includes/pluggable.php on line 228
could it be the different bbpress version? I use bbpress-0.9.0.2. Did you try it with this version?
I use the same version here, btw. if you replace the code I posted one message before the errors should go, check this first.
I tried that already and the posting before was the result. Can you post the complete fixed script somewhere ;-)
Many Thanks
I will post a new release the next days
Have you any Idea, when you are ready?
thanks for the reminder ;)
Quote from: Olaf
"Hi,
what is your role on your forum? do you tried a second (admin) account?"
I am the keymaster. I just setup another user as a moderator and now it appears that the checkbox is missing from the profile page, so I'm not sure how to activate this anymore.
I'd also like to point out that I have this topic as a favorite and I have the 'notify me when a post occurs to my favorites' checked in my profile, but I haven't received any emails with notifications of posts since my first post.
I will check this too
I finally got an email from the forum when I created a new topic under my own username.
However, it came from (unknown sender), which makes me think that may be why my server is blocking the emails most of the time.
Could that be the issue? If so, how do I set it up to send from one of my email addresses or the address that the forum uses for emails?
I think it's because the mail function for bbpress is very simple. I'm busy to create a plugin to send mails with phpmailer
Hi Olaf, this script is still not working well;-(
it works here fine since many weeks...
Please post the working code or a link here again, because I have still problems to get any mail from my bbpress.
don't forget that receiving auto generated email messages are a common problem these days
I uploaded the fixed version (replaced the static database table names)
you can download the version 1.02 from here:
http://www.finalwebsites.com/bbpress/moderator-notification.php
Note this version will use the bbpress mail function instead of the native PHP mail function. If you still have problems with receiving emails, you should have the same problem with registrations and other mails send by bbpress.
Quote from: Erdna
"Please post the working code or a link here again, because I have still problems to get any mail from my bbpress."
btw. do you activated the option from your profile?
from the readme file:
Every Key Master, Administrator and Moderator has check the option Moderator Post Notification via the Edit profile option to get e-mails from every regular member post.
Sorry, but I get still an error when I want to check the admin box to receive mails.
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /homepages/34/d21941373/htdocs/forum/my-plugins/moderator_notification.php on line 49
just created an administrator account and checked also the notification option, result:
it works, maybe you should check the data via phpmyadmin, it looks to me that the roles doesn't exists.
btw. do you use bbpress together with wordpress?
I use bbpress as standalone forum.
I tried the script at two different webhoster (strato and 1und1) at my strato-vserver it works fine (and it really sends mails!!) and on 1und1 I even cannot see the checkbox to make my hock. On this page I see this error..
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /homepages/34/d21941373/htdocs/forum/my-plugins/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 /homepages/34/d21941373/htdocs/forum/my-plugins/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 /homepages/34/d21941373/htdocs/forum/my-plugins/moderator_notification.php on line 49
If it works with strato and not with 1 and 1, it's bad for 1 and 1 customers but I don't understand why for the plugin?
next you can try the strato database on you 1 and 1 hosting account.
Does the php version matter? At the 1und1 server (plugin not working) is php 4.4.9, and on the strato server runs 5.1.2.
No, I don't think it's the PHP version but maybe some other php setting like magic quotes
Magic_quotes_ are the same settings at 1und1 and Strato :-(
The plugin has the name "bb_capabilities" hardcoded but if the installation has a prefix defined then it will fail because prefix is added to the capabilities also thus becoming "somePrefix_bb_capabilities".
Quote from: rfc137
"The plugin has the name "bb_capabilities" hardcoded but if the installation has a prefix defined then it will fail because prefix is added to the capabilities also thus becoming "somePrefix_bb_capabilities"."
yes right that was posted here before, we will fix this with an update later
I can not activate it in bbPress 1.0.2 I get
Plugin could not be activated, it produced a Fatal Error. The error is shown below.
Fatal error: Cannot redeclare is_moderator() (previously declared in /xxx/bbpress/my-plugins/bb-seo-tools.php:166) in /xxx/bbpress/my-plugins/moderator_notification.php on line 56
Hi Satmaster,
thats possible, you need to use a function_exists statement (check the PHP manual how-to do this)
I will update the code to fix this in future versions
Thanks
Quote from: paulf
"I'd also like to point out that I have this topic as a favorite and I have the 'notify me when a post occurs to my favorites' checked in my profile, but I haven't received any emails with notifications of posts since my first post."
Wow I just started getting notifications of this thread. Too bad I'm using a completely different system now.
you mean you removed bbpress?
Hi Olaf
I'm having the same problem - when I activate the plugin (version 1.0.1) I get the error message:
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /homepages/25/d263871326/htdocs/FSPW_NewWP/Forum/my-plugins/moderator-new-post-notification/moderator_notification.php on line 40
Repeated three times - this occurs where I assume the checkbox to receive notifications should be.
If I try to edit the user and click on Update Profile, I get a blank page with that error repeated again three times followed by the headers already sent error message, telling me that the headers were already sent by /bb-includes/functions.bb-pluggable.php
I'm using bbPress version 1.0.2 and I have it integrated with WordPress, so my users table is NOT bb_users, it's wp_users.
Can you help with this?
Hello TrishaM,
I never tried, the plugin together with Wordpress, since all users are shared with WP it might be a problem. Since I can't track down this problem (no wordpress + bbpress setup), I can't fix it for you.
I think the problem is here in your code - it has hard coded to pull users from bb_users, but that is not the table name for my users - instead it is wp_users. So can I just change this code below to replace bb_users and bb_usermeta with wp_users and wp_usermeta? I don't know how to tell it to use the right tables in the bb-config.php file and can't find any info on how to do that.
function is_moderator($user_id) {
global $bbdb;
$mods = array('moderator', 'administrator', 'keymaster');
$is_mod = false;
$row = $bbdb->get_row("SELECT um.meta_value AS role
FROM bb_users AS u, bb_usermeta AS um
WHERE u.ID = um.user_id
AND um.meta_key = 'bb_capabilities'
AND u.user_status = 0
AND u.ID = $user_id
");
Well that seems to work. So the problem is caused by the fact that the plugin is looking for a user table called bb_users and bb_usermeta, which don't exist, since I have bbPress integrated with Wordpress to share the user table.
I suggest then that you modify the plugin to have an admin setting for folks who are using it in a WP integrated setup and sharing a user table to tell the plugin that fact.
Cheers!
Hey Trish, the information is here available now, so people can change it (if needed).
I don't modify the plugins for wordpress until the bbpress/wordpress connection works for 100%.
There are so many complains that WP/bpress stuff is not working. I'm happy with bbpress (standalone)...
btw. the current version has already dynamic table names, you should use the version from this website ;)