Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter bobemil

    (@bobemil)

    Okey, sure!

    Core features

    • You got a personal message from “John Doe”
    • “John Doe” wants to be your friend
    • “John Doe” replied to your group forums thread

    Popular plugins (These would be amazing to include)

    • Buddypress Like – “John Doe” liked your blog post
    • Buddypress Followers – “John Doe” started following you
    Thread Starter bobemil

    (@bobemil)

    I tried to setup the notifications by myself but it’s not working (blank page). I used these code snippets in the bp-like.php file inside the plugin folder (adopted from Buddypress Followers plugin) . If you want to help me and understand how to set it up, I will pay 20$ through PayPal.

    function bp_like_setup_globals() {
    	global $bp, $wpdb;
    
    	// For internal identification
    	$bp->like->id              = 'like';
    
    	/* Register this in the active components array */
    	$bp->active_components[$bp->like->id] = $bp->like->id;
    
    	// BP 1.2.x only
    	if ( version_compare( BP_VERSION, '1.3' ) < 0 ) {
    		$bp->like->format_notification_function = 'bp_like_format_notifications';
    	}
    	// BP 1.5-specific
    	else {
    		$bp->like->notification_callback        = 'bp_like_format_notifications';
    	}
    }
    add_action( 'bp_setup_globals', 'bp_likesetup_globals' );
    /**
     * bp_like_process_ajax()
     *
     * Runs the relevant function depending on what Ajax call has been made.
     *
     */
    function bp_like_process_ajax() {
    	global $bp;
    
    	$id = preg_replace( "/\D/", "", $_POST['id'] ); 
    
    	if ( $_POST['type'] == 'like' )
    		bp_like_add_user_like( $id, 'activity' );
    
    	if ( $_POST['type'] == 'unlike' )
    		bp_like_remove_user_like( $id, 'activity' );
    
    	if ( $_POST['type'] == 'view-likes' )
    		bp_like_get_likes( $id, 'blogpost' );
    
    	if ( $_POST['type'] == 'like_blogpost' )
    		bp_like_add_user_like( $id, 'blogpost' );
    		bp_core_add_notification( $bp->like->id, 'new_like' );
    
    	if ( $_POST['type'] == 'unlike_blogpost' )
    		bp_like_remove_user_like( $id, 'blogpost' );
    
    	die();
    }
    add_action( 'wp_ajax_activity_like', 'bp_like_process_ajax' );
    /**
     * Format on screen notifications into something readable by users.
     *
     * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     */
    function bp_like_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format ) {
    	global $bp;
    
    	do_action( 'bp_like_format_notifications', $action, $item_id, $secondary_item_id, $total_items, $format );
    
    	switch ( $action ) {
    		case 'new_like':
    			$link = bp_loggedin_user_domain();
    
    			if ( 1 == $total_items ) {
    				$text = __( '1 user likes your shot', 'bp-like' );
    			}
    			else {
    				$text = sprintf( __( '%d users likes your shot', 'bp-like' ), $total_items );
    			}
    		break;
    
    		default :
    			$link = apply_filters( 'bp_like_extend_notification_link', false, $action, $item_id, $secondary_item_id, $total_items );
    			$text = apply_filters( 'bp_like_extend_notification_text', false, $action, $item_id, $secondary_item_id, $total_items );
    		break;
    	}
    
    	if ( !$link || !$text )
    		return false;
    
    	if ( 'string' == $format ) {
    		return apply_filters( 'bp_like_new_followers_notification', '<a href="' . $link . '" title="' . __( 'Your shot', 'bp-follow' ) . '">' . $text . '</a>', $total_items, $link, $text, $item_id, $secondary_item_id );
    	}
    	else {
    		$array = array(
    			'text' => $text,
    			'link' => $link
    		);
    
    		return apply_filters( 'bp_like_new_like_return_notification', $array, $item_id, $secondary_item_id, $total_items );
    	}
    }
    Thread Starter bobemil

    (@bobemil)

    Sorry, I don’t know what was wrong. It works now!

Viewing 3 replies - 1 through 3 (of 3 total)