GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-created_by-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default created by field output template.
4  *
5  * @global \GV\Template_Context $gravityview
6  * @since 2.0
7  */
8 
9 if ( ! isset( $gravityview ) || empty( $gravityview->template ) ) {
10  gravityview()->log->error( '{file} template loaded without context', array( 'file' => __FILE__ ) );
11  return;
12 }
13 
14 $value = $gravityview->value;
15 $field_settings = $gravityview->field->as_configuration();
16 
17 // There was no logged in user.
18 if ( empty( $value ) ) {
19  return;
20 }
21 
22 // Get the user data for the passed User ID
23 $user = get_userdata( $value );
24 
25 if ( ! $user ) {
26  return;
27 }
28 
29 // Display the user data, based on the settings `id`, `username`, or `display_name`
30 $name_display = empty( $field_settings['name_display'] ) ? 'display_name' : $field_settings['name_display'];
31 
32 switch ( true ):
33  // column
34  case in_array( $name_display, array( 'ID', 'user_login', 'display_name', 'user_email', 'user_registered' ), true ):
35  echo esc_html( $user->$name_display );
36  break;
37  // meta
38  case in_array( $name_display, array( 'nickname', 'description', 'first_name', 'last_name' ) ):
39  echo esc_html( get_user_meta( $user->ID, $name_display, true ) );
40  break;
41  // misc
42  case 'first_last_name':
43  echo esc_html( trim( sprintf( '%s %s', get_user_meta( $user->ID, 'first_name', true ), get_user_meta( $user->ID, 'last_name', true ) ) ) );
44  break;
45  case 'last_first_name':
46  echo esc_html( trim( sprintf( '%s %s', get_user_meta( $user->ID, 'last_name', true ), get_user_meta( $user->ID, 'first_name', true ) ) ) );
47  break;
if(empty( $value)) $user
if(! isset( $gravityview)||empty( $gravityview->template)) $value
The default created by field output template.
gravityview()
The main GravityView wrapper function.
if(! $user) $name_display