Created
September 4, 2020 12:47
-
-
Save mohammadYousefiDev/7996fd2ab817524c71e66c361419a6be to your computer and use it in GitHub Desktop.
sort netsted record in wp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//referral post type | |
//iranam plugin | |
function sort_referral($mains, $user_id) | |
{ | |
$result = []; | |
foreach( $mains as $key=>$main ) | |
{ | |
$data = $main; | |
if( (int)$main->post_author == $user_id ) | |
{ | |
$email = $main->post_content; | |
$user = get_user_by( 'email', $email ); | |
$id = $user->ID; | |
$mains[$key]->child = $this->sort_referral($mains, $id); | |
$result[] = $main; | |
} | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment