Created
December 23, 2020 13:33
-
-
Save reachkamrul/65ed276d1c78f096ddb1333bdd9d13fa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
/** | |
* WP USER LIST | |
*/ | |
add_filter('fluenform_rendering_field_data_select', function ($data, $form) { | |
if ($form->id != 7) { | |
return $data; | |
} | |
// check if the name attriibute is 'dynamic_dropdown' | |
if (\FluentForm\Framework\Helpers\ArrayHelper::get($data, 'attributes.name') != 'dropdown') { | |
return $data; | |
} | |
/* | |
USERS RULES IN WP | |
administrator | |
editor | |
author | |
contributor | |
subscriber | |
*/ | |
//Getting all user inside this $userArray | |
$userArray=[]; | |
//Calling the users inside this $allUsers | |
$allUsers=get_users('role=administrator'); | |
//Looping them and creating the dropdown option | |
foreach($allUsers as $user){ | |
$siteUsers=[ | |
"label" => $user->display_name, | |
"value" => $user->display_name, | |
"calc_value" => "" | |
]; | |
//Now put the users inside this $userArray | |
$userArray[]=$siteUsers; | |
} | |
// Lastly returnig the data in the fornend | |
$data['settings']['advanced_options'] =$userArray; | |
return $data; | |
}, 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment