-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcustom-functions.php
151 lines (128 loc) · 3.31 KB
/
custom-functions.php
1
<?phpadd_filter('manage_users_columns', 'add_parent');add_filter('manage_users_custom_column', 'add_parent_column_value', 10, 3);function add_parent($columns){ $columns['parent_name'] = __('Parent', 'binary-mlm-pro'); return $columns;}function add_parent_column_value($value, $column_name, $user_id){ global $wpdb; if ('parent_name'==$column_name) { return 'test'; } }// Use for withdrawal request mail to adminfunction WithDrawalProcessMail($Id,$comment,$amount){global $wpdb;$table_prefix = mlm_core_get_table_prefix();$comment=$comment;$admin_mail=get_option('admin_email');$res = $wpdb->get_var(" SELECT user_id FROM {$table_prefix}mlm_users WHERE `id` = '".$Id."' ");$user_info = get_userdata($res);$username = $user_info->user_login;$first_name = $user_info->first_name;$last_name = $user_info->last_name;$name=$first_name." ".$last_name;if(empty($first_name) && empty($first_name)) {$name=$username;} $amount=$amount;$to =$admin_mail;$headers = "MIME-Version: 1.0" . "\r\n";$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";$headers .= 'From: Admin <'.$admin_mail.'>' . "\r\n";$subject='New Withdrawal by '.$username;$message = "<html><head><title>New Withdrawal by ".$username."</title></head><body><p>Hello Admin,</p></br><p>A new withdrawal has been initiated by ".$username.". The withdrawal details are as follows:</p></br><table><tr><td><strong>Name:</strong></td><td>".$name."</td></tr><tr><td><strong>Amount:</strong></td><td>".$amount."</td></tr><tr><td><strong>Comment:</strong></td><td>".$comment."</td></tr></table><p>You can login to the admin section of you site and go to Binary MLM -> User Withdrawals to Process / Delete this withdrawal.</p></br><p>Thanks</p><p>".get_bloginfo( 'name' )." Admin </p></body></html>";wp_mail( $to, $subject, $message, $headers);}add_action('get_footer','saveCookies',25);function saveCookies(){global $wpdb,$table_prefix; if(!empty($_GET['sp_name'])) { $sp_name = $wpdb->get_var("select username from {$table_prefix}mlm_users where username='".$_GET['sp_name']."'"); if($sp_name) { ?> <script type='text/javascript'> jQuery.cookie('sp_name','<?= $sp_name ?>',{ path: '/' }); </script> <?php } } else if(!empty($_REQUEST['sp'])) { $sp_name = $wpdb->get_var("select username from {$table_prefix}mlm_users where user_key='".$_REQUEST['sp']."'"); if($sp_name){ ?> <script type='text/javascript'> jQuery.cookie('sp_name','<?= $sp_name ?>',{ path: '/' }); </script> <?php } } /* else { $sp_name = $wpdb->get_var("select username from {$table_prefix}mlm_users order by id ASC Limit 1"); if($sp_name){ ?> <script type='text/javascript'> jQuery.cookie('sp_name','<?= $sp_name ?>',{ path: '/' }); </script> <?php } }*///echo $sp_name;}function calculatelegUsersByPayoutId($user_key, $payout_id){ for ($x = $payout_id; $x >= 0; $x--) { $pid[] = $x; } $payout_id = implode("','", $pid); $left_users = totalLeftLegUsersByPayoutId($user_key, $payout_id); $right_users = totalRightLegUsersByPayoutId($user_key, $payout_id); if ($left_users < $right_users) { $pairs = $left_users; } else { $pairs = $right_users; } return array('l'=>$left_users,'r'=>$right_users,'p'=>$pairs);}?>