# How to get the current\_user details in Discourse.Dialect.postProcessText for both client and server side?

**URL:** <https://meta.discourse.org/t/how-to-get-the-current-user-details-in-discourse-dialect-postprocesstext-for-both-client-and-server-side/48391>\
**Category:** Development\
**Created:** [2016 年8 月 9 日 11:07 UTC](https://meta.discourse.org/t/how-to-get-the-current-user-details-in-discourse-dialect-postprocesstext-for-both-client-and-server-side/48391 "2016-08-09T11:07:34Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

作者： ![krishnau2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/krishnau2/32/121598_2.png) [@krishnau2](https://meta.discourse.org/u/krishnau2)\
发布日期： [2016 年8 月 11 日 13:59 UTC](https://meta.discourse.org/t/how-to-get-the-current-user-details-in-discourse-dialect-postprocesstext-for-both-client-and-server-side/48391/6 "2016-08-11T13:59:20Z")

</div>

@cpradio Thanks for the clarification, I was actually using the old plugin interface to manipulate text in the editor.

I tried the new way as shown by @tgxworld, Unfortunately even that didn’t work. I ended up in the same situation. Here is the sample code

```
import { registerOption } from 'pretty-text/pretty-text';

registerOption((siteSettings, opts) => {
  opts.features["sensitive_content_masking"] = true;
});

function maskSensitiveContent(text, user){
 
  var result = text. //Performing my regex and masking

  if(user !== null && (user.admin === true || user.moderator === true)){
    return text;
  }else{
    return result;
  }
}

export function setup(helper){
  helper.addPreProcessor(text => {
    return maskSensitiveContent(text, helper.getOptions().currentUser);
  });
}

```

This works perfectly in the editor and I can see int the preview section that the content is getting masked.  
But when I save this I am getting error `Cannot read property 'admin' of undefined/nTypeError:` of around this line

> <https://github.com/discourse/discourse/blob/main/lib/pretty_text.rb#L162>

Seems like `currentUser` or not even the `opts` is available in the server side when it try to cook with the V8 context.

---

_[View the full topic](https://meta.discourse.org/t/how-to-get-the-current-user-details-in-discourse-dialect-postprocesstext-for-both-client-and-server-side/48391)._
