• I can’t seem to find if this is even possible!

    I have a website which has a Directory Plugin and my Clients are entering their Contact Details ie: Phone Number, email etc in the DESCRIPTION of a Post. I don’t want then to be able to do this.

    The Plugin makes use of the Default WordPress edit functions for posts and pages.

    What I want to accomplish is to filter out any email, or numbers entered in the Description window of the edit screen so that if they enter an email address or phone numbers they are informed this is not allowed or possible.

    If there is a plugin that does this? can someone kindly point me in the right direction. Or would this be custom code?

    Wayne

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Almost anything is possible with custom coding. Doing so properly in the WP environment can be challenging at times, but there is almost always a way. For the best UX, it would be ideal to do these checks client side with JavaScript. string.search() supports regexp. There are regexp examples available to correctly identify email addresses. Finding numbers with regexp is straight forward, but could match legitimate number usage in descriptions. You could only match number segments at least 3 digits long to avoid false positives, but some addresses could slip through.

    Of course anything enforced by JS can be gotten around by clever users, so for absolute enforcement, values need to be rechecked again server side. Since this seems to be more of an annoyance than a security issue, you could well decide rechecking server side would not be necessary.

    A JS solution would add a listener to the description field that checks content any time the field changes. A warning could be injected into a div container intended for messaging. There’s a fair chance there already is one you could use. For adding JS code to WP admin pages, see wp_enqueue_script(). Pay attention to the actions to which your callback should be hooked that are listed in the notes.

    Thread Starter wayneoz

    (@wayneoz)

    Thank you for your detailed answer. I think this is way beyond my capabilities.

    Kind Regards,
    Wayne

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Disallow Numbers and Email in Posts and pages’ is closed to new replies.