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.

Strip HTTP from field

  1. Fonzzzie
    Member

    Hi,

    I am making a form where users can add a website. the website url will also be the title and the permalink addition. However i wish to remove http:// or if exsists http://www. to make my post tiltle and permalink more clean.

    How could i do such?

    BR

    Posted 13 years ago on Monday February 21, 2011 | Permalink
  2. This isn't possible as a built in feature. You would have to use hooks and write custom code to do this. It is only possible as a customization using available API hooks to manipulate the form data. How comfortable are you with PHP and WordPress hook/filter usage?

    Posted 13 years ago on Monday February 21, 2011 | Permalink
  3. Fonzzzie
    Member

    Well, honestly i am not comfortable with it at all...

    Posted 13 years ago on Monday February 21, 2011 | Permalink
  4. To clarify. What you want to do is use the Post Title field and on submit you want to automatically strip out "http://" and/or "http://www." is that correct?

    We may be able to write a code snippet for you that does this as it is fairly simple, but I would need to verify that this is indeed exactly what you want it to do.

    Posted 13 years ago on Monday February 21, 2011 | Permalink
  5. Fonzzzie
    Member

    What i do is, I let visitors enter a URL thru a form. e,g, http://www.domain.com.
    Currently I take the info from the URL field and set it as title of a Post.

    Create Post title template
    Insert from Field
    {Website:5}

    In the body of the post i will reuse the URL for linking to the website.

    But now the title and permalink will contain http://www. and httpwww.
    So what i want to do is to strip out the http://www. (or only http:// if www is not used) so i can have a clean title and permalink, and I also want to reuse the clean domain link to automatically create a thumbnail of the website. This would also require the http://www. to be stripped out.

    Ideally i would have another variable {Website-stripped} to re-use in the post body.

    I hope it clarifies your question.

    Posted 13 years ago on Wednesday February 23, 2011 | Permalink
  6. Haha, this one turned out to be a little trickier than I thought... but here is a solution for you.

    • 1 - Paste the following code into your theme's functions.php: http://pastie.org/1598990
    • 2 - Update your Post Title / Post Body Content Template to include this "[strip={Website:5}]" wherever you'd like just the domain name. Example: http://grab.by/973R
    • That's it. :)

    Note: You can still use the {Website:5} token with the [strip=] to display the full URL.

    Posted 13 years ago on Wednesday February 23, 2011 | Permalink
  7. Fonzzzie
    Member

    Thanks so far... I think i am placing the code wrongly as i get this message:

    Warning: Cannot modify header information - headers already sent by (output started at /home1/laptopt1/public_html/domain/wp-content/themes/twentyten/functions.php:1) in /home1/laptopt1/public_html/domain/wp-includes/classes.php on line 1601

    I should not include the PHP "quotes" at the beginning and end right? Because then i will get a parse error.

    Posted 13 years ago on Thursday February 24, 2011 | Permalink
  8. Hi Fonzzzie,

    The top of your functions.php file should already have an opening PHP tag "<?php" and the the bottom you will find a closing PHP tag "?>". I would recommend pasting this code at the very bottom just before the closing PHP tag "?>". If the issue persists, post a screenshot of the placement of your code. :)

    Posted 13 years ago on Thursday February 24, 2011 | Permalink
  9. Fonzzzie
    Member

    I have followed your steps again, and it seems to be working now! GREAT.

    However, with each solution there is a new problem.
    I want to insert "[strip={Website:5}]" into a shortcode,
    [screenshot url="[strip=http://www.domain.com]"] but you can imagine that is not going to work.

    Posted 13 years ago on Thursday February 24, 2011 | Permalink
  10. Fonzzzie
    Member

    OK Guys, I have been trying and testing but i can't seem to get it right.

    [screenshot url="[strip=http://www.domain.com]"] doesnt work, so i need to get the stripped domain in another format. I have tried to set de default value of a hidden field to [strip={Website:5}] and then use the {hidden field} to get the data back into the string [screenshot url="{hidden field}"]. But or it doesnt work like that, or i am using the wrong settings. Please give me a hint on how i can do it. (As last resort i could use the title as it is the stripped url, but in future i want also other entries besides URL's so then i would be in trouble later.

    Also the visitors can add an RSS url (optional) which displays the last 10 posts.
    The RSS URL can be added if a checkbox is checked. (conditional)
    I can get the last items on the website, no problem. But I also want to display the text "last 10 posts from [strip={Website:5}]": " But of course only if visitor enters a RSS url.
    So adding the text to the template will not work as it will always display this text.

    So can i e.g. put in some field (e.g. RSS) "last 10 itmes : [rssinpage rssfeed=''domain.com/rss"] " and put the shortcode {rss} in the template to display the data?

    Posted 13 years ago on Monday February 28, 2011 | Permalink
  11. @fonzzzie You can't execute a shortcode within a schortcode like that. You would have to modify the [screenshot] shortcode so it incorporates the code of the [strip] shortcode and applies it to the url="" that is passed to it. So you have to merge those 2 shortcodes you are using so that the [screenshot] shortcode takes care of it for you.

    We can't write that code for you, it's a customization so it's something you will have to piece together from what has already been provided or consider hiring a developer to take care of the customization for you.

    Posted 13 years ago on Monday February 28, 2011 | Permalink

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