KI-Zusammenfassung
Beschreibung
Der wpforms_smart_tag_process Filter wird verwendet, um Smart Tags innerhalb des WPForms Form Builders zu verarbeiten.
Parameter
- $inhalt
- (string) (Erforderlich) Inhalt des Smart Tags.
- $tag
- (string) (Erforderlich) Tag-Name des Smart Tags.
Quelle
wpforms/includes/class-smart-tags.php
Weitere Informationen
Der Filter wird verwendet, um Smart Tags zu erstellen, zu definieren und zu registrieren, die im WPForms Form Builder verwendet werden sollen.
Die Verwendung dieses Filters muss auch von wpforms_smart_tags begleitet werden, der den Smart Tag vor der Verarbeitung registriert.
Beispiel
/**
* 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 );
Referenzartikel
- Einen benutzerdefinierten Smart Tag erstellen
- Erstellen eines Smart Tag für die aktuelle Uhrzeit
- So erstellen Sie eine eindeutige ID für jeden Formulareintrag
- So erstellen Sie weitere Benutzer-Smart-Tags
- So fügen Sie die Beitrags-URL von Einreichungen zur Bestätigungsnachricht hinzu
- Erstellen eines Smart Tags aus einem ACF-Feld
- Erstellen einer Smart Tag Domain-URL