bp_xprofile_validate_social_networks_value( $retval, $field_id, string $value, string $user_id = null )
Validate social networks field values.
Description
Parameters
- $retval
-
(Required)
- $field_name
-
(Required)
- $value
-
(Required)
- $user_id
-
(Optional)
Default value: null
Return
($retval)
Source
File: bp-xprofile/bp-xprofile-filters.php
function bp_xprofile_validate_social_networks_value( $retval, $field_id, $value, $user_id = null ) {
$field = xprofile_get_field( $field_id, null, false );
// Allows storing the 'facebook', 'twitter' and so on as array keys in the data.
if ( 'socialnetworks' !== $field->type ) {
return $retval;
}
if ( $retval ) {
return $retval;
}
$field_name = xprofile_get_field( $field_id )->name;
if ( 1 === $field->is_required ) {
foreach ( $value as $key => $val ) {
$value = trim($val);
if (empty($value))
return sprintf( __( '%s is required and not allowed to be empty.', 'buddyboss' ), $field_name );
}
}
$providers = social_network_provider();
foreach ( $value as $k => $v ) {
if ( '' === $v || filter_var( $v, FILTER_VALIDATE_URL) ) {
} else {
$key = bp_social_network_search_key( $k, $providers);
return sprintf( __( 'Please enter valid %s profile url.', 'buddyboss' ), $providers[$key]->name );
}
}
return $retval;
}
Changelog
| Version | Description |
|---|---|
| BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.