Created
October 6, 2025 04:33
-
-
Save TanvirAmi/01ad7db0bf5fe3d826a6daebfba125e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add Shortcode | |
function subform() { | |
// Start output buffering | |
ob_start(); | |
// Get the current user's info | |
$current_user = wp_get_current_user(); | |
$user_display_name = !empty( $current_user->user_firstname ) ? $current_user->user_firstname : $current_user->display_name; | |
// Get the blog name | |
$blog_name = get_bloginfo( 'name' ); | |
// Display the welcome message and subscription form | |
echo '<p>Hey ' . esc_html( $user_display_name ) . ', welcome to ' . esc_html( $blog_name ) . '! You can subscribe to our newsletter here:</p>'; | |
?> | |
<form action="/thank-you"> | |
<label for="email">Enter your email:</label> | |
<input type="email" id="email" name="email"> | |
<input type="submit" value="Submit"> | |
</form> | |
<?php | |
} | |
add_shortcode( 'subscriptionform', 'subform' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment