wpcf7_user_related_smt()
Returns output string of a special mail-tag.
Хуков нет.
Возвращает
Строку. Output of the given special mail-tag.
Использование
wpcf7_user_related_smt( $output, $name, $html, $mail_tag );
- $output(строка) (обязательный)
- The string to be output.
- $name(строка) (обязательный)
- The tag name of the special mail-tag.
- $html(true|false) (обязательный)
- Whether the mail-tag is used in an HTML content.
- $mail_tag(WPCF7_MailTag)
- An object representation of the mail-tag.
По умолчанию:null
Код wpcf7_user_related_smt() wpcf7 user related smt CF7 6.1.5
function wpcf7_user_related_smt( $output, $name, $html, $mail_tag = null ) {
if ( ! $mail_tag instanceof WPCF7_MailTag ) {
wpcf7_doing_it_wrong(
sprintf( '%s()', __FUNCTION__ ),
__( 'The fourth parameter ($mail_tag) must be an instance of the WPCF7_MailTag class.', 'contact-form-7' ),
'5.2.2'
);
}
if ( ! str_starts_with( $name, '_user_' ) or '_user_agent' === $name ) {
return $output;
}
$submission = WPCF7_Submission::get_instance();
if ( ! $submission ) {
return $output;
}
$user_id = (int) $submission->get_meta( 'current_user_id' );
if ( ! $user_id ) {
return '';
}
$primary_props = array( 'user_login', 'user_email', 'user_url' );
$opt = ltrim( $name, '_' );
$opt = in_array( $opt, $primary_props, true ) ? $opt : substr( $opt, 5 );
$user = new WP_User( $user_id );
if ( $user->has_prop( $opt ) ) {
return (string) $user->get( $opt );
}
return '';
}