Adding preset domain to a get email

I’m trying to collect only part of an email address from the frontend user and add the domain (@test.com) automatically in the code. It is in HTML, but the string for the email is PHP. I would imagine that I need to concatenate the string with the domain I want. Maybe .“test.com” ?? This is the bit of code I’m working with:

	<input type="email"
   name="ywgc-recipient-email[]" <?php echo ( $mandatory_recipient && ! $gift_this_product ) ? 'required' : ''; ?>
   class="ywgc-recipient yith_wc_gift_card_input_recipient_details" placeholder="<?php _e( "Email", 'yith-woocommerce-gift-cards' ); ?>"/>

	<input type="text" name="ywgc-recipient-name[]" placeholder="<?php _e( "name", 'yith-woocommerce-gift-cards' ); ?>" <?php echo ( $mandatory_recipient && ! $gift_this_product ) ? 'required' : ''; ?> class="yith_wc_gift_card_input_recipient_details">

	<a href="#" class="ywgc-remove-recipient hide-if-alone">x</a>
	<?php if ( ! $mandatory_recipient ): ?>
		<span class="ywgc-empty-recipient-note"><?php echo apply_filters( 'ywgc_empty_recipient_note', __( "Example D9", 'yith-woocommerce-gift-cards' ) ); ?></span>
	<?php endif; ?>
</div>

I would sure appreciate some guidance here.

Where are you trying to add this domain to? (where is you want this displayed?)

It looks to me like there is only a placeholder that displays any email?

You showed us your HTML code. What about the PHP code?
So, you have an email input area.
You need to add some code to get the posted value.
Then, you can manipulate the received data any way you wish.
In the PHP code, you would use filter_input to protect the data from hackers.
Then, use string searches to locate the break point in the incoming text and then concat the domain to the end of the data. All of this is simple code. What part do you not understand?
Please give us more info so we can help you solve it.

The bit of code I posted is part of an e-card plugin where the user can insert am email address where the e-card will be mailed to. But this service is for family of prisoners to send season greeting cards to prisoners. There are 12 buildings, and I have created 12 email accounts where the card can be mailed to. I have changed the label of the email input field to “Building Number” where I only want the user to insert D1 or D2 …D12) and have the domain (cida.site) added in the email input string automatically.
I have managed to do a “choose” array where they can select the appropriate email addres from an array list. (Code I used shown below). But this is not ideal because it may confuse some users due to the fact that the buildings in Thailand are known as D1 (Dan 1).

	<label
	for="ywgc-recipient-email">
	<?php if ( $mandatory_recipient ) {
		echo apply_filters('ywgc_editor_mandatory_recipient_email_label',__( "หมายเลขแดน(D1-D12) (*)", 'yith-woocommerce-gift-cards') );
	} else {
		echo apply_filters('ywgc_editor_recipient_email_label',__( "กดและเลือกจากรายชื่อ", 'yith-woocommerce-gift-cards' ));
	}
	?></label>

<div class="ywgc-single-recipient">

	<input type="email" list="defaultEmails" name="ywgc-recipient-email[]" <?php echo ( $mandatory_recipient && ! $gift_this_product ) ? 'required' : ''; ?>
   class="ywgc-recipient yith_wc_gift_card_input_recipient_details" placeholder="หมายเลขแดน"/>

	<datalist id="defaultEmails">
	<option value="D1@cida.site">
	<option value="D2@cida.site">
	<option value="D3@cida.site">
	<option value="D4@cida.site">
	<option value="D5@cida.site">
	<option value="D6@cida.site">
	<option value="D7@cida.site">
	<option value="D8@cida.site">
	<option value="D9@cida.site">
	<option value="D10@cida.site">
	<option value="D11@cida.site">
	<option value="D12@cida.site">
	</datalist>

As you can see it is a mix of HTML and PHP which I am struggling with.

Sponsor our Newsletter | Privacy Policy | Terms of Service