Skip to content

Instantly share code, notes, and snippets.

@juanramon
Created May 8, 2013 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanramon/5539374 to your computer and use it in GitHub Desktop.
Save juanramon/5539374 to your computer and use it in GitHub Desktop.
Function to check if the listings is going to be shared is an spam message.
<?php
function send_friend_post_akismet($item) {
// we don't performe this action if akismet is not
if( !osc_akismet_key() ) {
return false;
}
require_once osc_lib_path() . 'Akismet.class.php';
$akismet = new Akismet(osc_base_url(), osc_akismet_key());
$akismet->setCommentAuthor(Params::getParam('yourName'));
$akismet->setCommentAuthorEmail(Params::getParam('yourEmail'));
$akismet->setCommentContent(Params::getParam('message'));
$akismet->setPermalink(osc_item_url());
// Is Akismet saying it is spam?
if( $akismet->isCommentSpam() ) {
// define the message you want to show
osc_add_flash_error_message('Spam message');
header('Location: ' . osc_item_send_friend_url()); exit;
}
}
osc_add_hook('pre_item_send_friend_post', 'send_friend_post_akismet');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment