Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using buddypress and I offer users the chance to add links to their social networks (facebook/twitter) by entering the url's into custom profile fields. My issue is that people can;t follow directions and constantly enter in incomplete url's so I need to validate them while they're filling them out on profile edit and registration.

I found this nice little function to validate.

function validate_url(url) {
  if (/^(https?://)?((w{3}.)?)twitter.com/(#!/)?[a-z0-9_]+$/i.test(url))
   return 'valid';    

  if (/^(https?://)?((w{3}.)?)facebook.com/.*/i.test(url))
   return 'invalid';

  return 'not a valid link';
}

My question is how can I use this in conjunction with buddypress profile edit. I moved the bp template files to my child theme and started fooling around with the edit template under profiles but couldn’t really get anywhere. Any ideas on the best way to do this?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.