1. Home
  2. Docs
  3. Payment Withdrawal API
  4. Show and Save Manual/Automatic Payment fields

Show and Save Manual/Automatic Payment fields

Frontend :- Profile > Settings > Earning

/**
 * Protected constructor to prevent creating a new instance of the
 * *Singleton* via the `new` operator from outside of this class.
*/
protected function __construct() {
	add_action( 'prefive_show_withdraw_personalinfo_gateway', array( $this, 'show_payment_withdraw_personal_info' ) );
	add_action( 'prefive_save_withdraw_personalinfo_gateway', array( $this, 'save_payment_withdraw_personal_info' ) );
}


/*
 * Display payment fields required for manual and automated payment withdrawal in user's profile settings
 * This function is hooked to 'prefive_show_withdraw_personalinfo_gatway' action, which is used to display payment fields required for manual and automated payment withdrawal in user's profile settings.
 * You can add more fields. In below example, it is showing one field for manual and one field for automatic payment.
 */
function show_payment_withdraw_personal_info( $uid ) {
	if ( get_option( 'prefive_enable_sample_withdraw' ) != "no" ) { ?>
		
		<!-- Display manual payment fields here -->
		<div id="sample-payments" class="field">
			<label><?php _e('Sample Payments:', 'prefive'); ?></label>
			<div class="two fields">
				<div class="field">
					<input type="email" name="sample_payment_email" placeholder="<?php echo __( 'Sample Email', 'prefive-sample' ); ?>" value="<?php echo user( $uid, 'sample_payment_email' ); ?>" size="40" <?php if ( user( $uid, 'sample_payment_email' ) ) { echo 'readonly'; } ?> />
				</div>
			</div>
		</div>


	<?php }


	if ( get_option( 'prefive_enable_sample_withdraw_automatic' ) == "yes" ) { ?>
		
		<!-- Display automated payment fields here -->
		<div id="automated-sample-payments" class="field">
			<label><?php _e('Automated Sample Payments:', 'prefive'); ?></label>


			<div class="two fields">
				<div class="field">
					<input type="text" name="sample_automatic_payee_id" placeholder="<?php echo __( 'Sample Payee ID', 'prefive' ); ?>" value="<?php echo user( $uid, 'sample_automatic_payee_id' ); ?>" size="40" <?php if ( user( $uid, 'sample_automatic_payee_id' ) ) { echo 'readonly'; } ?> />
				</div>
			</div>
		</div>


	<?php }
}


/*
 * Save payment fields required for manual and automated withdrawal payments in user's profile settings
 * This function is hooked to 'prefive_save_withdraw_personalinfo_gateway' action, which is used to save payment fields required for manual and automated payment withdrawal in user's profile settings. 
 */
function save_payment_withdraw_personal_info( $uid ) {
	if ( ! user( $uid, 'sample_payment_email' ) ) {
		update_user_meta( $uid, 'sample_payment_email', $_POST['sample_payment_email'] );
	}
	if ( ! user( $uid, 'sample_automatic_payee_id' ) ) {
		update_user_meta( $uid, 'sample_automatic_payee_id', $_POST['sample_automatic_payee_id'] );
	}
}
Was this article helpful to you? Yes No

How can we help?