PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 2.1.4
JetFormBuilder — Dynamic Blocks Form Builder v2.1.4
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / presets / sources / preset-source-user.php
jetformbuilder / includes / presets / sources Last commit date
base-source.php 3 years ago preset-source-options-page.php 3 years ago preset-source-post.php 3 years ago preset-source-query-var.php 3 years ago preset-source-user.php 3 years ago
preset-source-user.php
59 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Presets\Sources;
5
6 class Preset_Source_User extends Base_Source {
7
8 public function get_id() {
9 return 'user';
10 }
11
12 public function on_sanitize(): bool {
13 if ( ! is_user_logged_in() ) {
14 return false;
15 }
16
17 if ( get_current_user_id() !== $this->src()->ID && ! current_user_can( 'edit_users' ) ) {
18 return false;
19 }
20
21 return true;
22 }
23
24 public function query_source() {
25 $user_from = ! empty( $this->preset_data['user_from'] ) ? $this->preset_data['user_from'] : 'current_user';
26
27 if ( 'current_user' === $user_from && is_user_logged_in() ) {
28 return wp_get_current_user();
29 }
30
31 $var = ! empty( $this->preset_data['query_var'] ) ? $this->preset_data['query_var'] : 'user_id';
32 $user_id = ( $var && isset( $_REQUEST[ $var ] ) ) ? absint( $_REQUEST[ $var ] ) : false;
33
34 return get_user_by( 'ID', $user_id );
35 }
36
37 /**
38 * @return mixed
39 */
40 protected function can_get_preset() {
41 return ( parent::can_get_preset()
42 && is_user_logged_in()
43 && ( get_current_user_id() === $this->src()->ID || current_user_can( 'edit_users' ) )
44 );
45 }
46
47 public function source__user_meta() {
48 if ( empty( $this->field_data['key'] ) ) {
49 return '';
50 }
51
52 return get_user_meta(
53 $this->src()->ID,
54 $this->field_data['key'],
55 true
56 );
57 }
58 }
59