Skip to:
Content

BuddyPress.org

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#6587 closed defect (bug) (no action required)

DATA BASE ERROR WHEN ADD notification

Reported by: chicho1969's profile chicho1969 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Core Keywords: reporter-feedback
Cc:

Description

Trying for weeks... WP 3.9.2 BuddyPress 2.3.2.1

function setup_globals( $args = array() ) {
global $bp;
$sr_notifications_test_slug = 'sr_notifications_test';
parent::setup_globals( array(
'id' => 'sr_notifications_test',
'slug' => $sr_notifications_test_slug,
'notification_callback' => array( $this, 'sr_format_notifications_test' )
) );
Register this in the active components array
$bp->active_components[$sr_notifications_test_slug] = 'sr_notifications_test';
do_action( 'setup_globals' );
}

format notofication
function sr_format_notifications_test( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {

switch ( $action ) {
case 'my_test':
$link = get_permalink( $item_id );
$text = 'Test Notification';

$return = apply_filters( $filter, array(
'text' => $text,
'link' => $link
), $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id );
break;
}

do_action( 'sr_format_notifications_test', $action, $item_id, $secondary_item_id, $total_items );
return $return;
}

Notification added to DB:
bp_notifications_add_notification( array(
'user_id' => $user_id,
'item_id' => $activity->id,
'secondary_item_id' => $activity->user_id,
'component_name' => buddypress()->activity->id,
'component_action' => 'my_test',
'date_notified' => bp_core_current_time(),
'is_new' => 1

) );

I try so many ways but afterall i have always the same error:

WordPress database error: [Table 'my_wp_db.n' doesn't exist]
SELECT * FROM n WHERE component_name IN ('activity') AND component_action IN ('my_test') AND is_new = 1
WordPress database error: [Incorrect table name ]
INSERT INTO (user_id,item_id,secondary_item_id,component_name,component_action,date_notified,is_new) VALUES (0,0,0,'activity','my_test','2015-08-12 16:58:14',1)

Change History (5)

#1 @imath
9 years ago

  • Keywords reporter-feedback added

Looks like the Notification component is not active. Have you checked the BuddyPress settings page to make sure it was active?

#2 @DJPaul
9 years ago

@chicho1969 did you get anywhere?

#3 @chicho1969
9 years ago

Hello,

Sorry @imath I had not seen your sugestio... but yes notification component is active and working.

To @DJPaul :

I have it working but in a very weird way.

I have two very strange solutions, that the only way i found.

First weird thing is from bp-functions in my bp folder within my theme _setup_globals functions only works if called directly from there.

And second weird thing is that my add_notification function is not working at all, even I tryed some many hooks, so I had to let the code to execute without making a function.

The code and the complite explanation is in this topic: https://buddypress.org/support/topic/need-urgent-help-with-bp-notifications/#post-243321 , please notice that the first posts are just a sample code, the real code is from the post linked.

I had to jump to another things in that development, but I´ll have go back to it in a couple of days.

#4 @r-a-y
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Make sure you are adding the notification when you need it (like after a blog post is recorded) and not too early.

You might also want to take a look at this reply to find out how to format notifications for your custom component without extending the BP_Component class:
https://buddypress.trac.wordpress.org/ticket/6669#comment:4

For now, I'm going to close this due to inactivity. Feel free to reopen if you still require help.

#5 @DJPaul
9 years ago

  • Component changed from API to Core
Note: See TracTickets for help on using tickets.