Support » Developing with WordPress » Creating user ID in an array

  • Resolved pandglobal


    add_filter( 'gravityflow_assignee_field_users', 'sh_gravityflow_assignee_field_users', 10, 3 );
    function sh_gravityflow_assignee_field_users( $users, $form_id, $field ) {
    	$users = array(
    		array( 'value' => 'user_id|2', 'text' => 'Joe' ),
    		array( 'value' => 'user_id|3', 'text' => 'Jane' ),
    	return $users;

    I want to include the current user ID and user name to be at the top list or first choice in that array field, or better still only output current user iD and user name in the array or drop down list, so if users login his name will only be the option available for selection from the array. if i can get one array or option of the current user i will be good.

Viewing 3 replies - 1 through 3 (of 3 total)
  • add_filter( 'gform_field_value_bank3_code', 'my_custom_population_showbank' );
    function my_custom_population_showbank( $value ) {
    	$current_user = wp_get_current_user();
    	$users = $current_user->userpinn;
        return $users;

    But i want if the value of the user metakey is Canada it should change Canada to a number like 340
    but if the value is America it should return 500

    The concept is that i want to pull user meta key of users in my website by their country. so the $current_user->userpinn; out puts the current user country on his metakey. using userpinn as country metakey.

    Now i want if the current user is from England it should return 400
    IF current user is from United Kingdom it should return 580
    If the current user is from Canada it should return 320
    Thats how i want to do it for each different country, instead of returning the England it should return number which is 400, and i want the function on a single text field or number field, not on a drop down list.

    Moderator Jan Dembowski


    Forum Moderator and Brute Squad

    @pandglobal Can you please not create multiple topics for the same thing? I’ve archived your new topic.

    You’re being helped here for this use of wp_get_current_user().

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.