III. Show and Save Manual and Automatic Payment Fields

(Front end: Profile -> Settings -> Payments)

/**
 * 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( 'wpjobster_show_withdraw_personalinfo_gateway', array( $this, 'show_payment_withdraw_personal_info' ) );
	add_action( 'wpjobster_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 'wpjobster_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( 'wpjobster_enable_sample_withdraw' ) != "no" ) { ?>
		
		<!-- Display manual payment fields here -->
		<div id="sample-payments" class="field">
			<label><?php _e('Sample Payments:', 'wpjobster'); ?></label>
			<div class="two fields">
				<div class="field">
					<input type="email" name="sample_payment_email" placeholder="<?php echo __( 'Sample Email', 'wpjobster-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( 'wpjobster_enable_sample_withdraw_automatic' ) == "yes" ) { ?>
		
		<!-- Display automated payment fields here -->
		<div id="automated-sample-payments" class="field">
			<label><?php _e('Automated Sample Payments:', 'wpjobster'); ?></label>


			<div class="two fields">
				<div class="field">
					<input type="text" name="sample_automatic_payee_id" placeholder="<?php echo __( 'Sample Payee ID', 'wpjobster' ); ?>" 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 'wpjobster_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'] );
	}
}