Home › Forums › Backend Issues (wp-admin) › Add http:// to ACF LINK › Reply To: Add http:// to ACF LINK
Hi,
i used $field[‘value’][‘url’] = “https”; because in my quck test it seems right.
And the other Problem, yeah, thats what i meant with
“if there is already a “good” url saved.”
You have to validate inside the function if $field[‘value’][‘url’] is already a valid url.
Should be something like these
if($field[‘value’][‘url’] != valid url){
//no valid url, fill the field with https/http
$field[‘value’][‘url’] = “https”;
}else{
//already a valid url here, nothing to do
}
return $field;
Sry, im not a php developer, but if you google for “php validate url” you should find something, thats fit.
I think this could work here: https://stackoverflow.com/questions/7003416/validating-a-url-in-php
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.