Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function get_affiliate_id ( ) {
- global $wpdb;
- $pname = get_option( 'aff_pname', AFFILIATES_PNAME );
- $affiliate_id = "";
- $user_id = get_current_user_id();
- if ( $user_id && affiliates_user_is_affiliate( $user_id ) ) {
- $affiliates_table = _affiliates_get_tablename( 'affiliates' );
- $affiliates_users_table = _affiliates_get_tablename( 'affiliates_users' );
- if ( $affiliate_id = $wpdb->get_var( $wpdb->prepare(
- "SELECT $affiliates_users_table.affiliate_id FROM $affiliates_users_table LEFT JOIN $affiliates_table ON $affiliates_users_table.affiliate_id = $affiliates_table.affiliate_id WHERE $affiliates_users_table.user_id = %d AND $affiliates_table.status = 'active'",
- intval( $user_id )
- ))) {
- $affiliate_id = affiliates_encode_affiliate_id( $affiliate_id );
- }
- }
- return $affiliate_id;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement