• Resolved czokalapik

    (@czokalapik)


    Is there an option to send message to user when someone will post a comment in user’s post or respond to comment user wrote?
    Is there any FEP action i can hook to with function on comment save ?

    I don’t want to install numerous plugins for different functionalities, i would like to use FEP as a message center, getting notifications about new comments through FEP would be awesome.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Shamim Hasan

    (@shamim51)

    You can easily achieve this functionality. On comment save you can use fep_send_message function to send a message.

    Thread Starter czokalapik

    (@czokalapik)

    if someone is interested i got it working:

    function add_private_msg( $comment_ID, $comment_approved ) {
    	if( 1 === $comment_approved ){
    		$admin_user = get_field('admin_user','options'); // "dummy" user ID with site logo in avatar etc, i did set it in Advanced Custom Fields, you can store this ID in another way and get it also in whatever way you want. This will be user sending message, you can set comment author here if you want.
    		$comment_id = get_comment( $comment_ID ); 
    		$postdata = get_post($comment_id->comment_post_ID);
    		if($postdata->post_author!=$comment_id->user_id) { //check if comment author is not post author (would be stupid to send msg about new comment to yourself :D
    			  $message['message_to_id'] = $postdata->post_author;
    			  $message['message_title'] = 'New comment';
    			  $message['message_content'] = 'You have new comment in <a href="'.get_comment_link($comment_id).'">'.$postdata->post_title.'</a>';
    			
    				$override = array (
    					'post_author' => $admin_user['ID'] // depending on how you got sender ID, you might need to set this var differently
    					);
    			  $x = fep_send_message($message, $override );
      //send msg from $admin_user to $postdata->post_author about $postdata->ID
    		}
    	}
    }
    add_action( 'comment_post', 'add_private_msg', 10, 2 );
    amirsamani

    (@amirsamani)

    i use above function in function.php of plugin but i got error :
    Call to undefined function get_field() in /home/hakimazm/public_html/wp-content/plugins/front-end-pm/functions.php on line 251
    please help me

    amirsamani

    (@amirsamani)

    i install Advanced Custom Fields plugin and above error has been solved, but i get new error:

    Fatal error: Call to undefined function fep_send_message() in /home/hakimazm/public_html/wp-content/plugins/front-end-pm/functions.php on line 262

    Thread Starter czokalapik

    (@czokalapik)

    fep_send_message() func is from this plugin.

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

The topic ‘Send Message on Comment’ is closed to new replies.