Riepilogo AI
Descrizione
Il wpforms_smart_tag_process utilizzato per elaborare gli Smart Tag all'interno del costruttore di moduli WPForms.
Parametri
- $contenuto
- (stringa) (obbligatorio) Contenuto dello Smart Tag.
- $tag
- (stringa) (obbligatorio) Nome del tag dello smart tag.
Fonte
wpforms/includes/class-smart-tags.php
Ulteriori informazioni
Il filtro è usato per creare, definire e registrare gli Smart Tag da usare all'interno del costruttore di moduli WPForms.
L'utilizzo di questo filtro deve essere accompagnato anche dal wpforms_smart_tags che registrerebbe lo smart tag prima di elaborarlo.
Esempio
/**
* Process the Smart Tag.
*
* @link https://wpforms.com/developers/wpforms_smart_tag_process/
*
* @param string $content Content of the Smart Tag.
* @param string $tag Tag name of the Smart Tag.
* @return string
*/
function wpf_dev_process_smarttag( $content, $tag ) {
$userID = get_current_user_id();
// Only run if it is our desired tag.
if ( 'wp_nickname' === $tag ) {
$wp_nickname = get_the_author_meta( 'nickname', $userID );
// Replace the tag with the nickname pulled from the user's WordPress profile.
$content = str_replace( '{wp_nickname}', $wp_nickname, $content );
}
if ( 'wp_username' === $tag ) {
$wp_username = get_the_author_meta( 'user_login', $userID );
// Replace the tag with the username pulled from the user's WordPress profile.
$content = str_replace( '{wp_username}', $wp_username, $content );
}
return $content;
}
add_filter( 'wpforms_smart_tag_process', 'wpf_dev_process_smarttag', 10, 2 );
Articoli di riferimento
- Come creare uno smart tag personalizzato
- Come creare uno smart tag per l'ora corrente
- Come creare un ID univoco per ogni inserimento di un modulo
- Come creare più tag intelligenti per gli utenti
- Come includere l'URL dei post inviati nel messaggio di conferma
- Come creare uno smart tag da un campo ACF
- Come creare un URL di dominio Smart Tag