Send to post author

Is there a way to include a shortcode in a post to allow subscribers to PM the author, then have the author be able to reply. Is there a way to filter content so user's can send email addresses over the PM system? Thanks in advance!

  • Luís

    Hi Andy ,

    Hope you're doing well today!

    Is there a way to include a shortcode in a post to allow subscribers to PM the author, then have the author be able to reply

    You can use the following shortcode to do that:

    [pm_user in_the_loop="1"]

    You can find all the supported parameters for this shortcode in Messaging -> Settings -> Shortcodes.

    Is there a way to filter content so user's can send email addresses over the PM system?

    Can you explain better what you want to achieve? Users can send email adresses in the messages.Or you want to disallow it?

    Cheers, Luís

  • Panos

    Hi Andy,

    Please try out the following snippet at your child theme's functions.php file:

    add_filter( 'wp_insert_post_data' , 'wpmudev_filter_emails' , '99', 2 );
    
    function wpmudev_filter_emails( $data , $postarr ) {
    
        if( $postarr['post_type'] == 'mm_message' ){
    
        	$pattern = "/[^@\s]*@[^@\s]*\.[^@\s]*/";
    		$replacement = "[email-removed]";
    		$data['post_content'] = preg_replace($pattern, $replacement, $data['post_content'] );
    
        	/*$pattern = "/[a-zA-Z]*[:\/\/]*[A-Za-z0-9\-_]+\.+[A-Za-z0-9\.\/%&=\?\-_]+/i";
    		$replacement = "[link-removed]";
    		$data['post_content'] = preg_replace($pattern, $replacement, $data['post_content']);*/
    
        }
    
        return $data;
    }

    If you need to wipe out urls too, simply uncomment the last lines in the snippet :slight_smile:

    Hope this helps!

    Cheers!
    Panos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.