Ease Validation rules for social media links - Social Links Plugin

Hi,

I just purchased and activated social links plugin but I found the validation to be too strict. It looks to me that you need https:// in the field for it to be seen as a valid URL.

Is there a way to relax this validation? or change the error message? I only discovered the https:// was all that was needed to trick the validation to think it’s a legitimate URL.

I think this validation is a bit dated as many websites now use domain.com/user as the url for users and advertise it as such. Even www is dropped.

If it’s needed for logics/coding in the back end then can we add an error message in that helps solve the issue e.g. “Please ensure URL is in this format http://www.socialmedia.com/example

Thanks

Thanks for your feedback, we’ll try to improve the UX of the URL fields. Currently we use the browser URL inputs and it seems that browsers require adding “http” or “https” to any input value.

1 Like

Thank you. What would be the easiest way to add a custom message so users know they need to add http in the form - as an immediate work around for the issue.

Cheers

Please try this PHP snippet

add_filter( 'hivepress/v1/models/listing/attributes', 'add_description_for_social_links', 100 );
add_filter( 'hivepress/v1/models/vendor/attributes', 'add_description_for_social_links', 100 );

function add_description_for_social_links($attributes){
	$model = explode( '/', current_filter() )[3];
	
	foreach ( hivepress()->social_links->get_links( $model ) as $name => $args ) {
		if(isset($attributes[ $name ]) && 'url' === $attributes[ $name ]['edit_field']['type']){
			$attributes[ $name ]['edit_field']['description'] = 'custom text';	
		}
	}
	return $attributes;
}