Frontier Post – Change moderation comments using Filter
Below is an example of how you can make your own moderation comments using filter – Add the below code to your functions.php and adapt it to your liking:
Requires: Frontier Post version 4.4.1 or above
function fp_my_mod_cmt( $fp_moderation_comments_new, $fp_moderation_comments_old, $my_post, $tmp_task_new, $formdata )
{
global $current_user;
$fp_my_cmts = mysql2date( 'd-m-Y', $my_post->post_date);
$fp_my_cmts .= " USER: ".$current_user->user_firstname." ".$current_user->user_lastname.":<br>";
$fp_my_cmts .= $fp_moderation_comments_new."<br>";
$fp_my_cmts .= '<hr>'."<br>";
$fp_my_cmts .= $fp_moderation_comments_old."<br>";
return $fp_my_cmts;
}
add_filter( 'frontier_post_mod_cmt_update', 'fp_my_mod_cmt', 20, 5 );
below is the code for the filter:
//***************************************************************************************
//* Save post moderation fields
//***************************************************************************************
if ( fp_get_option_bool("fps_use_moderation") && (current_user_can("edit_others_posts") || $current_user->ID == $my_post->post_author))
{
if (isset($_POST['frontier_post_moderation_new_text']))
{
$fp_moderation_comments_new = $_POST['frontier_post_moderation_new_text'];
//$fp_moderation_comments_new = trim(stripslashes(strip_tags($fp_moderation_comments_new)));
$fp_moderation_comments_new = wp_strip_all_tags($fp_moderation_comments_new);
$fp_moderation_comments_new = nl2br($fp_moderation_comments_new);
$fp_moderation_comments_new = stripslashes($fp_moderation_comments_new);
$fp_moderation_comments_new = trim($fp_moderation_comments_new);
if (strlen($fp_moderation_comments_new) > 0)
{
global $current_user;
//$tmp_date_format = fp_get_option('fps_date_format_lists', 'Y-m-d');
$fp_moderation_comments_old = get_post_meta( $my_post->ID, 'FRONTIER_POST_MODERATION_TEXT', true );
//$fp_moderation_comments = current_time( 'mysql')." - ".$current_user->user_login.":<br>";
$fp_moderation_comments = mysql2date(fp_get_option('fps_date_format_lists', 'Y-m-d'), $my_post->post_date);
$fp_moderation_comments .= " - ".$current_user->user_login.":<br>";
$fp_moderation_comments .= $fp_moderation_comments_new."<br>";
$fp_moderation_comments .= '<hr>'."<br>";
$fp_moderation_comments .= $fp_moderation_comments_old."<br>";
//****************************************************************************************************
// Apply filter before update of moderation comments
// filter: frontier_post_mod_cmt_update
// $fp_moderation_comments_new New comments entered by the users
// $fp_moderation_comments_old Previous Comments
// $my_post Post record object
// $tmp_task_new Equals true if the user is adding a post
// $_POST Input form
// FRONTIER_POST_MODERATION_TEXT in $_POST is where the moderation momments are enterd
//****************************************************************************************************
$fp_moderation_comments = apply_filters( 'frontier_post_mod_cmt_update', $fp_moderation_comments_new, $fp_moderation_comments_old, $my_post, $tmp_task_new, $_POST );
update_post_meta( $my_post->ID, 'FRONTIER_POST_MODERATION_TEXT', $fp_moderation_comments );
update_post_meta( $my_post->ID, 'FRONTIER_POST_MODERATION_DATE', current_time( 'mysql'));
update_post_meta( $my_post->ID, 'FRONTIER_POST_MODERATION_FLAG', 'true');
// Email author on moderation comments
if (isset($_POST['frontier_post_moderation_send_email']) && $_POST['frontier_post_moderation_send_email'] == "true")
{
$to = get_the_author_meta( 'email', $my_post->post_author );
$subject = __("Moderator has commented your pending post", "frontier-post")." (".get_bloginfo( "name" ).")";
$body = __("Moderator has commented your pending post", "frontier-post").": ".$my_post->post_title ." (".get_bloginfo( "name" ).")"."\r\n\r\n";
$body .= "Comments: ".$_POST['frontier_post_moderation_new_text']."\r\n\r\n";
if( !wp_mail($to, $subject, $body ) )
frontier_post_set_msg(__("Message delivery failed - Recipient: (", "frontier-post").$to.")");
}
}
}
}
.
Comments
Frontier Post – Change moderation comments using Filter — No Comments
HTML tags allowed in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>