mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Merge pull request #953 from ultimatemember/feature/discord_field
Discord field (issue #926)
This commit is contained in:
@@ -1029,6 +1029,19 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
|||||||
'match' => 'https://t.me/',
|
'match' => 'https://t.me/',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
'discord' => array(
|
||||||
|
'title' => __('Discord','ultimate-member'),
|
||||||
|
'metakey' => 'discord',
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => __('Discord ID','ultimate-member'),
|
||||||
|
'required' => 0,
|
||||||
|
'public' => 1,
|
||||||
|
'editable' => 1,
|
||||||
|
'url_target' => '_blank',
|
||||||
|
'url_rel' => 'nofollow',
|
||||||
|
'validate' => 'discord',
|
||||||
|
),
|
||||||
|
|
||||||
'youtube' => array(
|
'youtube' => array(
|
||||||
'title' => __('YouTube','ultimate-member'),
|
'title' => __('YouTube','ultimate-member'),
|
||||||
'metakey' => 'youtube',
|
'metakey' => 'youtube',
|
||||||
@@ -1455,6 +1468,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
|||||||
$array['url'] = __('Website URL','ultimate-member');
|
$array['url'] = __('Website URL','ultimate-member');
|
||||||
$array['youtube_url'] = __('YouTube Profile','ultimate-member');
|
$array['youtube_url'] = __('YouTube Profile','ultimate-member');
|
||||||
$array['telegram_url'] = __('Telegram URL','ultimate-member');
|
$array['telegram_url'] = __('Telegram URL','ultimate-member');
|
||||||
|
$array['discord'] = __('Discord ID','ultimate-member');
|
||||||
$array['custom'] = __('Custom Validation','ultimate-member');
|
$array['custom'] = __('Custom Validation','ultimate-member');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -284,6 +284,24 @@ if ( ! class_exists( 'um\core\Validation' ) ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is Discord ID
|
||||||
|
*
|
||||||
|
* @param $string
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function is_discord_id( $string ) {
|
||||||
|
if ( ! $string ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ( ! preg_match( '/(^\S+)#(\d+)$/', trim( $string ) ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is url
|
* Is url
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -758,6 +758,12 @@ function um_submit_form_errors_hook_( $args ) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'discord':
|
||||||
|
if ( ! UM()->validation()->is_discord_id( $args[ $key ] ) ) {
|
||||||
|
UM()->form()->add_error( $key, __( 'Please enter a valid Discord ID', 'ultimate-member' ) );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'url':
|
case 'url':
|
||||||
if ( ! UM()->validation()->is_url( $args[ $key ] ) ) {
|
if ( ! UM()->validation()->is_url( $args[ $key ] ) ) {
|
||||||
UM()->form()->add_error( $key, __( 'Please enter a valid URL', 'ultimate-member' ) );
|
UM()->form()->add_error( $key, __( 'Please enter a valid URL', 'ultimate-member' ) );
|
||||||
|
|||||||
Reference in New Issue
Block a user