<?php
if ( ! function_exists( 'wpj_get_user_credit' ) ) {
	function wpj_get_user_credit( $uid = '' ) {
		if ( ! $uid ) $uid = get_current_user_id();

		$credits = get_user_meta( $uid, 'credits', true );

		if ( empty( $credits ) ) {
			$credits = 0;

			update_user_meta( $uid, 'credits', '0' );
		}

		return $credits;
	}
}

if ( ! function_exists( 'wpj_update_user_credit' ) ) {
	function wpj_update_user_credit( $uid = '', $amount = '' ) {
		if ( ! $uid ) $uid = get_current_user_id();

		update_user_meta( $uid, 'credits', $amount );
	}
}