1

I have a contact us form built using the RSForm Pro component.
At the top of the form I have a brief intro-text, using the RSForm freetext field, where I have my email address for those that don't want to submit the form and just like to contact me directly.

I have my form published with a RS Form menu item.
My problem is that the email cloaking plugin doesn't affect the email address that is shown inside rsform.

How can I hide my email address from bots?

3

Below are 2 options:

1. Display the form within Joomla Article.

The first one is to inject and publish the form within a joomla article, where the cloaking plugin will be triggered. RS Form component comes with the required plugin that allows to show a form within an article.

However this might cause further issues with how the form will deal any other email addresses from inside the form, but in this case, there are instructions in RS Joomla site to deal with this.

2. Use PHP inside RS Form.

The other option, is to manipulate the form's output with php, within RS Form.
This is possible with the RS Form's feature, to run php code that is called on Form Display.

Here is how to achieve it:
In the freetext field of the form, you can replace the email address with a special keyword, which you can enclose inside brackets.

E.g. Feel free to drop us an email at {email}.

the '{email}' is the special keyword.

Then from the Form Properties, in the PHP Scripts section, you can add the following piece of code at the first script text-area, that manipulates the form's display.

  //First we use Joomla's default email cloaking feature:
  $email = JHtml::_('email.cloak', 'myemail@mydomain.com');

  //Then we replace the keyword we placed previously in the freetext, with the new value of email.
  $formLayout = str_replace('{email}',$email, $formLayout);

The $formLayout is the string that contains the layout of the form. We search for our keyword inside this string and replace it with the new "cloaked" email value $email.

Now the email address will be protected from spambots in the front-end.

  • Alternatively you might be able to use Regularlab's email protector. I've not tested it with RSform, but apparently it "is a system plugin and is written in a way that it will cloak email adresses in your entire website. So also in modules and 3rd party extensions." – TryHarder Mar 19 '18 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.