PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Controlling Post Links

  1. selym
    Member

    I was wonder if there was any way to control post links through Gravity Forms. For example, I have an open front end form that anyone can post with, and I set this up to post under a subscriber user I created. The only problem is users can post external links which I'd like to prevent. I have not found any plugins that will control this sort of thing by role.

    Just curious if there was anything that can be done from within GF that I am unaware of. I doubt there is, but I still wanted to ask. :)

    Thanks,
    Sel

    Posted 13 years ago on Sunday October 30, 2011 | Permalink
  2. You want to prevent URLs from being submitted with your form? All URLs, or just some? Can you explain more about why this is important, or what you are trying to prevent?

    You can filter the content in a couple different ways, and can strip out any links or html if you like. But I'd like to hear more about what you're trying to accomplish.

    Posted 13 years ago on Sunday October 30, 2011 | Permalink
  3. selym
    Member

    Hi Chris,

    I would like to prevent all urls from being submitted with my form. I found a plugin that can put a custom url in front of any link, which if I use my own url, I can ensure the links will at least stay on my site (and go to my 404). Not exactly ideal, but better than nothing for now.

    The only problems are that 1) the aforementioned plugin works on all links no matter who submits (admin/me or someone from the front end form) and 2) users can still submit ad scripts to a post such as Adsense (and possibly others) and it works.

    I'm experimenting with the idea of an anonymous message server and I'm just trying to take out all the obvious forms of abuse (profanity filter, link and advertisement disabling, etc.) before anything else.

    Thanks
    Sel

    Posted 13 years ago on Sunday October 30, 2011 | Permalink
  4. Is it OK if the link text is there, but it's not clickable? It would not be a hyperlink, just text, like this: example.net

    That's a URL but is not automatically hyperlinked. Would that be a good solution, or do you want the text removed? And if removed, what should be in its place?

    Posted 13 years ago on Sunday October 30, 2011 | Permalink
  5. selym
    Member

    I don't mind the urls remaining as long as they're not hyperlinked, although if the raw html has to be included with it, I'd prefer it's all replaced with with a "link removed" type message.

    But honestly, if its just a standard http://www.url.com without it being hyperlinked, I'd be fine just letting it remain as regular text.

    Thanks,
    Sel

    Posted 13 years ago on Sunday October 30, 2011 | Permalink
  6. Can you post a link to your form? I didn't think URLs were auto-hyperlinked in WordPress without a plugin, so a URL submitted with a form should NOT show up as a clickable link. Try submitted a URL here then check the post to see if it's linked.

    http://gravity.chrishajer.com/story-submission/

    Here's one I added (nothing is hyperlinked):
    http://gravity.chrishajer.com/2011/10/30/no-hyperlinks/

    Maybe you are using a plugin or something in functions.php that will auto-hyperlink URLs in your site?

    Posted 13 years ago on Monday October 31, 2011 | Permalink
  7. BTW, the URLs are hyperlinked here because that functionality is built in to bbPress, not WordPress.

    Also, the URL in the notification might be hyperlinked as well. I know Gmail does it automatically. I'm not sure if the link in the {all_fields} notification is linked by default, or if it's just Gmail doing it. It would not be a hyperlink on your site though.

    Posted 13 years ago on Monday October 31, 2011 | Permalink
  8. selym
    Member

    Hi Chris,

    It's the form here: http://bit.ly/v08cnN

    Correct, urls are not automatically hyperlinked, but if I put the html around it in the forms body field, the link will be published.

    I also tested by posting some google adsense code into the post body field and the image banner showed up, which would be problematic in my case.

    Thanks,
    Sel

    Posted 13 years ago on Monday October 31, 2011 | Permalink
  9. selym
    Member

    Ha, and yes, gmail definitely does hyperlink them automatically. Just noticed that on my blackberry when my last test form submission came though. ;)

    Sel

    Posted 13 years ago on Monday October 31, 2011 | Permalink
  10. Do you still need help with this? The text submitted by the user is not hyperlinked, correct?

    Posted 13 years ago on Tuesday November 1, 2011 | Permalink
  11. selym
    Member

    Well, yes, they are still hyperlinked if the user submits with html (a href=blah blah, etc) in the form.

    Thanks,
    Sel

    Posted 13 years ago on Wednesday November 2, 2011 | Permalink
  12. Right, if you allow HTML and they use HTML, it will be hyperlinked if they submit that.

    In version 1.6 there is a filter for allowable HTML tags gform_allowable_tags. You could use that and remove the < a href > tag. Or, you could filter the post content to strip out HTML, using the gform_post_submission (gform_after_submission in 1.6 and later) filter.

    Prior to 1.6: gform_post_submission
    1.6 and later: gform_after_submission

    Posted 13 years ago on Wednesday November 2, 2011 | Permalink
  13. selym
    Member

    Ok, so if I'm understanding correctly based on your first link, I would add an allowable tags filter into form_display.php?

    It says the default is always false, so would that mean I add that first gform_allowable_tags filter (for all forms) with no function and it will not allow html?

    Is there a document that explains how to write these filters/functions properly? So if I wanted to play around with things and only wanted to remove < a href > like you said, but keep automatic paragraph breaks or something. When I searched for filters, I got hundreds of docs back with specific filters, but not a lot of info about how to manipulate them or include/exclude certain things.

    Thanks,
    Sel

    Posted 13 years ago on Wednesday November 2, 2011 | Permalink
  14. 1. No, you never modify the core Gravity Forms files. That code goes into your current theme's functions.php.

    The documentation you need is all located here:
    http://www.gravityhelp.com/documentation/page/Developer_Docs

    They're in a section called developer docs because some of them do require a bit of knowledge of WordPress hooks, filters and actions, and some PHP. If you look in your theme's functions.php you might see some of these types of filters and actions already being implemented, and might be able to follow along.

    Posted 13 years ago on Wednesday November 2, 2011 | Permalink
  15. selym
    Member

    Ok, I'm running Thesis, and I somewhat recognize those types of things, but that doesn't mean I truly understand it all. :( If I add the following into my custom_functions.php, should the return only allow new paragraph and bold markup? And if I put "false" in its place, would it not allow any html? Doesn't seem to work for me yet, so I must have something not right.

    add_filter("gform_allowable_tags", "allow_basic_tags");
    function allow_basic_tags($allowable_tags){
    return '<p>'; }

    Don't feel like you have to respond any more. You've baby sat me long enough. I'll keep reading, playing with it, testing. It's just an uphill battle when you're not a programmer.

    Thanks,
    Sel

    Posted 13 years ago on Wednesday November 2, 2011 | Permalink
  16. I think you're close. I will have one of the programmers take a look at this and see if they have any suggestions. You're close to getting it.

    Posted 13 years ago on Wednesday November 2, 2011 | Permalink
  17. Hi Sel,

    I assume you are using the "Post Body" field to enter your message? If so, the issue is likely not with your use of the filter, but the fact that the filter does not apply to any of the Post fields. All of these fields accept HTML by default. We discussed internally and decided it make a lot of sense to allow the "gform_allowable_tags" filter to apply to ALL Gravity Form fields.

    I've sent you an updated version of Gravity Forms where this is the case. Let me know if you encounter any issues after installing. The existing code you've placed in your theme's functions.php file should not require any change with this new version.

    Posted 13 years ago on Wednesday November 2, 2011 | Permalink
  18. selym
    Member

    Worked perfectly, thank you very much Chris and David.

    Thanks,
    Sel

    Posted 13 years ago on Thursday November 3, 2011 | Permalink

This topic has been resolved and has been closed to new replies.