PageRenderTime 133ms CodeModel.GetById 75ms app.highlight 49ms RepoModel.GetById 1ms app.codeStats 1ms

/wp-content/plugins/wp-types/embedded/usermeta-init.php

https://bitbucket.org/acipriani/madeinapulia.com
PHP | 1139 lines | 820 code | 121 blank | 198 comment | 180 complexity | 64f7ade230cf5fd0150c02197ee5a2b2 MD5 | raw file
   1<?php
   2// Add usermeta and post fileds groups to access.
   3$usermeta_access = new Usermeta_Access;
   4$fields_access = new Post_Fields_Access;
   5//setlocale(LC_ALL, 'nl_NL');
   6
   7/**
   8 * Add User Fileds menus, need add to wpcf_admin_menu_hook
   9 *
  10 * @author Gen gen.i@icanlocalize.com
  11 * @since Types 1.3
  12 *
  13 * $HeadURL: https://www.onthegosystems.com/misc_svn/cck/tags/1.6.3/embedded/usermeta-init.php $
  14 * $LastChangedDate: 2014-09-09 10:46:42 +0000 (Tue, 09 Sep 2014) $
  15 * $LastChangedRevision: 26873 $
  16 * $LastChangedBy: gen $
  17 *
  18 */
  19function wpcf_admin_menu_edit_user_fields_hook() {
  20    do_action( 'wpcf_admin_page_init' );
  21
  22    // Group filter
  23    wp_enqueue_script( 'wpcf-filter-js',
  24            WPCF_EMBEDDED_RES_RELPATH
  25            . '/js/custom-fields-form-filter.js', array('jquery'), WPCF_VERSION );
  26    // Form
  27    wp_enqueue_script( 'wpcf-form-validation',
  28            WPCF_EMBEDDED_RES_RELPATH . '/js/'
  29            . 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
  30            WPCF_VERSION );
  31    wp_enqueue_script( 'wpcf-form-validation-additional',
  32            WPCF_EMBEDDED_RES_RELPATH . '/js/'
  33            . 'jquery-form-validation/additional-methods.min.js',
  34            array('jquery'), WPCF_VERSION );
  35    // Scroll
  36    wp_enqueue_script( 'wpcf-scrollbar',
  37            WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/scrollbar.js',
  38            array('jquery') );
  39    wp_enqueue_script( 'wpcf-mousewheel',
  40            WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/mousewheel.js',
  41            array('wpcf-scrollbar') );
  42    //Css editor
  43    wp_enqueue_script( 'wpcf-form-codemirror',
  44            WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.js',
  45            array('wpcf-js') );
  46    wp_enqueue_script( 'wpcf-form-codemirror-css-editor',
  47            WPCF_RELPATH . '/resources/js/codemirror234/mode/css/css.js',
  48            array('wpcf-js') );
  49    wp_enqueue_script( 'wpcf-form-codemirror-html-editor',
  50            WPCF_RELPATH . '/resources/js/codemirror234/mode/xml/xml.js',
  51            array('wpcf-js') );
  52    wp_enqueue_script( 'wpcf-form-codemirror-html-editor2',
  53            WPCF_RELPATH . '/resources/js/codemirror234/mode/htmlmixed/htmlmixed.js',
  54            array('wpcf-js') );
  55    wp_enqueue_script( 'wpcf-form-codemirror-editor-resize',
  56            WPCF_RELPATH . '/resources/js/jquery_ui/jquery.ui.resizable.min.js',
  57            array('wpcf-js') );
  58
  59
  60
  61    wp_enqueue_style( 'wpcf-css-editor',
  62            WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.css' );
  63    wp_enqueue_style( 'wpcf-css-editor-resize',
  64            WPCF_RELPATH . '/resources/js/jquery_ui/jquery.ui.theme.min.css' );
  65    wp_enqueue_style( 'wpcf-usermeta',
  66            WPCF_EMBEDDED_RES_RELPATH . '/css/usermeta.css' );
  67    
  68    // MAIN
  69    wp_enqueue_script( 'wpcf-fields-form',
  70            WPCF_EMBEDDED_RES_RELPATH
  71            . '/js/fields-form.js', array('wpcf-js') );
  72
  73    /*
  74     * Enqueue styles
  75     */
  76    wp_enqueue_style( 'wpcf-scroll',
  77            WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/css/scroll.css' );
  78
  79    add_action( 'admin_footer', 'wpcf_admin_fields_form_js_validation' );
  80    require_once WPCF_INC_ABSPATH . '/fields.php';
  81    require_once WPCF_INC_ABSPATH . '/usermeta.php';
  82    require_once WPCF_INC_ABSPATH . '/fields-form.php';
  83    require_once WPCF_INC_ABSPATH . '/usermeta-form.php';
  84    $form = wpcf_admin_usermeta_form();
  85    wpcf_form( 'wpcf_form_fields', $form );
  86
  87}
  88
  89/**
  90 * Add/Edit usermeta fields group
  91 *
  92 * @author Gen gen.i@icanlocalize.com
  93 * @since Types 1.3
  94 */
  95function wpcf_admin_menu_edit_user_fields() {
  96    if ( isset( $_GET['group_id'] ) ) {
  97        $title = __( 'Edit Usermeta Group', 'wpcf' );
  98    } else {
  99        $title = __( 'Add New Usermeta Group', 'wpcf' );
 100    }
 101    echo wpcf_add_admin_header( $title );
 102
 103    $form = wpcf_form( 'wpcf_form_fields' );
 104    echo '<br /><form method="post" action="" class="wpcf-fields-form '
 105    . 'wpcf-form-validate" onsubmit="';
 106    echo 'if (jQuery(\'#wpcf-group-name\').val() == \'' . __( 'Enter group title',
 107            'wpcf' ) . '\') { jQuery(\'#wpcf-group-name\').val(\'\'); }';
 108    echo 'if (jQuery(\'#wpcf-group-description\').val() == \'' . __( 'Enter a description for this group',
 109            'wpcf' ) . '\') { jQuery(\'#wpcf-group-description\').val(\'\'); }';
 110    echo 'jQuery(\'.wpcf-forms-set-legend\').each(function(){
 111        if (jQuery(this).val() == \'' . __( 'Enter field name',
 112            'wpcf' ) . '\') {
 113            jQuery(this).val(\'\');
 114        }
 115        if (jQuery(this).next().val() == \'' . __( 'Enter field slug',
 116            'wpcf' ) . '\') {
 117            jQuery(this).next().val(\'\');
 118        }
 119        if (jQuery(this).next().next().val() == \'' . __( 'Describe this field',
 120            'wpcf' ) . '\') {
 121            jQuery(this).next().next().val(\'\');
 122        }
 123	});';
 124    echo '">';
 125    echo $form->renderForm();
 126    echo '</form>';
 127    echo wpcf_add_admin_footer();
 128}
 129
 130/**
 131 * Add Usermeta Fields manager page.
 132 *
 133 * @author Gen gen.i@icanlocalize.com
 134 * @since Types 1.3
 135 */
 136function wpcf_admin_menu_user_fields_control_hook() {
 137    do_action( 'wpcf_admin_page_init' );
 138
 139    add_action( 'admin_head', 'wpcf_admin_user_fields_control_js' );
 140    add_thickbox();
 141    require_once WPCF_INC_ABSPATH . '/fields.php';
 142    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
 143    require_once WPCF_INC_ABSPATH . '/fields-control.php';
 144    require_once WPCF_INC_ABSPATH . '/usermeta-control.php';
 145
 146    if ( isset( $_REQUEST['_wpnonce'] )
 147            && wp_verify_nonce( $_REQUEST['_wpnonce'],
 148                    'user_fields_control_bulk' )
 149            && (isset( $_POST['action'] ) || isset( $_POST['action2'] )) && !empty( $_POST['fields'] ) ) {
 150        $action = $_POST['action'] == '-1' ? $_POST['action2'] : $_POST['action'];
 151        wpcf_admin_user_fields_control_bulk_actions( $action );
 152    }
 153
 154    global $wpcf_control_table;
 155    $wpcf_control_table = new WPCF_User_Fields_Control_Table( array(
 156                'ajax' => true,
 157                'singular' => __( 'User Field', 'wpcf' ),
 158                'plural' => __( 'User Fields', 'wpcf' ),
 159                    ) );
 160    $wpcf_control_table->prepare_items();
 161}
 162
 163/**
 164 * Menu page display.
 165 */
 166function wpcf_admin_menu_user_fields_control() {
 167    global $wpcf_control_table;
 168    echo wpcf_add_admin_header( __( 'User Fields Control', 'wpcf' ) );
 169    echo '<br /><form method="post" action="" id="wpcf-custom-fields-control-form" class="wpcf-custom-fields-control-form '
 170    . 'wpcf-form-validate" enctype="multipart/form-data">';
 171    echo wpcf_admin_custom_fields_control_form( $wpcf_control_table );
 172    wp_nonce_field( 'user_fields_control_bulk' );
 173    echo '</form>';
 174    echo wpcf_add_admin_footer();
 175}
 176
 177/**
 178 * Usermeta groups listing
 179 *
 180 * @author Gen gen.i@icanlocalize.com
 181 * @since Types 1.3
 182 */
 183function wpcf_usermeta_summary() {
 184    echo wpcf_add_admin_header( __( 'User Fields', 'wpcf' ) );
 185    require_once WPCF_INC_ABSPATH . '/fields.php';
 186    require_once WPCF_INC_ABSPATH . '/usermeta.php';
 187    require_once WPCF_INC_ABSPATH . '/usermeta-list.php';
 188    $to_display = wpcf_admin_fields_get_fields();
 189    if ( !empty( $to_display ) ) {
 190        add_action( 'wpcf_groups_list_table_after',
 191                'wpcf_admin_promotional_text' );
 192    }
 193    wpcf_admin_usermeta_list();
 194    echo wpcf_add_admin_footer();
 195}
 196
 197//Add usermeta hook when user profile loaded
 198add_action( 'show_user_profile', 'wpcf_admin_user_profile_load_hook' );
 199add_action( 'edit_user_profile', 'wpcf_admin_user_profile_load_hook' );
 200
 201//Save usermeta hook
 202add_action( 'personal_options_update', 'wpcf_admin_user_profile_save_hook' );
 203add_action( 'edit_user_profile_update', 'wpcf_admin_user_profile_save_hook' );
 204
 205
 206
 207/**
 208 * Add usermeta groups to post editor
 209 */
 210add_filter( 'editor_addon_menus_types',
 211        'wpcf_admin_post_add_usermeta_to_editor_js' );
 212
 213
 214add_action( 'load-post.php', '__wpcf_usermeta_test', PHP_INT_MAX );
 215add_action( 'load-post-new.php', '__wpcf_usermeta_test', PHP_INT_MAX );
 216if ( is_admin() ) {
 217    add_filter( 'wpcf_post_groups', '__wpcf_usermeta_test_groups' );
 218}
 219
 220function __wpcf_usermeta_test() {
 221    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
 222    $field['id'] = md5( 'date' . time() );
 223    $here = array(basename( $_SERVER['REQUEST_URI'] ), basename( $_SERVER['SCRIPT_FILENAME'] ));
 224    global $post;
 225    // Get post_type
 226    if ( $post ) {
 227        $post_type = get_post_type( $post );
 228    } else if ( !empty( $_GET['post'] ) ) {
 229        $post_type = get_post_type( $_GET['post'] );
 230    }
 231    if ( ( $here[0] == ('index.php' || 'wp-admin')) && ( $here[1] != 'index.php') ) {
 232        if ( isset( $post_type )
 233                && in_array( $post_type,
 234                        array('view', 'view-template', 'cred-form') ) ) {
 235            return;
 236        }
 237        wpcf_admin_post_add_to_editor( $field );
 238    }
 239}
 240
 241function __wpcf_usermeta_test_groups( $groups ) {
 242    if ( !empty( $groups ) ) {
 243        return $groups;
 244    }
 245    $groups = wpcf_admin_fields_get_groups( 'wp-types-user-group' );
 246    $check = false;
 247    if ( !empty( $groups ) ) {
 248
 249        foreach ( $groups as $group_id => $group ) {
 250
 251            // Mark meta box as hidden
 252            $groups[$group_id]['__show_meta_box'] = false;
 253
 254            if ( empty( $group['is_active'] ) ) {
 255                unset( $groups[$group_id] );
 256                continue;
 257            }
 258            $fields = wpcf_admin_fields_get_fields_by_group( $group['id'],
 259                    'slug', true, false, true, 'wp-types-user-group',
 260                    'wpcf-usermeta' );
 261            if ( empty( $fields ) ) {
 262                unset( $groups[$group_id] );
 263                continue;
 264            }
 265            $check = true;
 266        }
 267    }
 268    if ( !$check ) {
 269        remove_action( 'admin_enqueue_scripts',
 270                'wpcf_admin_post_add_to_editor_js' );
 271    } else {
 272        wpcf_edit_post_screen_scripts();
 273    }
 274    return $groups;
 275}
 276
 277if ( !isset( $_GET['post_type'] ) && isset( $_GET['post'] ) ) {
 278    $post_type = get_post_type( $_GET['post'] );
 279} else if ( isset( $_GET['post_type'] ) && in_array( $_GET['post_type'],
 280                get_post_types( array('show_ui' => true) ) ) ) {
 281    $post_type = $_GET['post_type'];
 282}
 283
 284/*
 285 * 
 286 * This is not needed for Views 1.3
 287 * Kept for compatibility with older versions
 288 */
 289if ( isset( $post_type ) && in_array( $post_type,
 290                array('view', 'view-template', 'cred-form') ) ) {
 291    add_filter( 'editor_addon_menus_wpv-views',
 292            'wpcf_admin_post_add_usermeta_to_editor_js' );
 293    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
 294    add_action( 'admin_footer', 'wpcf_admin_post_js_validation' );
 295    //wpcf_enqueue_scripts();
 296}
 297
 298/**
 299 * Get current logged user ID
 300 *
 301 * @author Gen gen.i@icanlocalize.com
 302 * @since Types 1.3
 303 */
 304function wpcf_usermeta_get_user( $method = '' ){
 305    if ( empty( $method ) ) {
 306        $current_user = wp_get_current_user();
 307        $user_id = $current_user->ID;
 308    }
 309
 310    return $user_id;
 311}
 312
 313/**
 314 * Add User Fields to editor
 315 *
 316 * @author Gen gen.i@icanlocalize.com
 317 * @since Types 1.3
 318 */
 319function wpcf_admin_post_add_usermeta_to_editor_js( $items, $views_callback = false ){
 320    global $wpcf;
 321
 322    $post = wpcf_admin_get_edited_post();
 323    if ( empty( $post ) ) {
 324        $post = (object) array('ID' => -1);
 325    }
 326
 327    $groups = wpcf_admin_fields_get_groups( 'wp-types-user-group' );
 328    $user_id = wpcf_usermeta_get_user();
 329    $add = array();
 330    if ( !empty( $groups ) ) {
 331        $item_styles = array();
 332        foreach ( $groups as $group_id => $group ) {
 333            if ( empty( $group['is_active'] ) ) {
 334                continue;
 335            }
 336            $group['name'] .= ' (User meta fields)';
 337            $fields = wpcf_admin_fields_get_fields_by_group( $group['id'],
 338                    'slug', true, false, true, 'wp-types-user-group',
 339                    'wpcf-usermeta' );
 340
 341            if ( !empty( $fields ) ) {
 342                foreach ( $fields as $field_id => $field ) {
 343                    // Use field class
 344                    $wpcf->usermeta_field->set( $user_id, $field );
 345
 346                    // Get field data
 347                    $data = (array) $wpcf->usermeta_field->config;
 348
 349                    // Get inherited field
 350                    if ( isset( $data['inherited_field_type'] ) ) {
 351                        $inherited_field_data = wpcf_fields_type_action( $data['inherited_field_type'] );
 352                    }
 353
 354                    $callback = 'wpcfFieldsEditorCallback(\'' . $field['id']
 355                            . '\', \'usermeta\', ' . $post->ID . ')';
 356                            
 357                    // Added for Views:users filter Vicon popup
 358                    if ( $views_callback ){
 359                        $callback = 'wpcfFieldsEditorCallback(\'' . $field['id']
 360                            . '\', \'views-usermeta\', ' . $post->ID . ')';
 361                    }        
 362
 363                    $add[$group['name']][stripslashes( $field['name'] )] = array(stripslashes( $field['name'] ), trim( wpcf_usermeta_get_shortcode( $field ),
 364                                '[]' ), $group['name'], $callback);
 365                }
 366                /*
 367                 * Since Types 1.2
 368                 * We use field class to enqueue JS and CSS
 369                 */
 370                $wpcf->usermeta_field->enqueue_script();
 371                $wpcf->usermeta_field->enqueue_style();
 372            }
 373        }
 374    }
 375
 376    $items = $items + $add;
 377    return $items;
 378
 379}
 380
 381/**
 382 * Returns shortcode for specified usermeta field.
 383 *
 384 * @param type $field
 385 * @param type $add Additional attributes
 386 */
 387function wpcf_usermeta_get_shortcode( $field, $add = '', $content = '' ) {
 388    /*if ( isset($_GET['field_type']) && $_GET['field_type'] =='views-usermeta' ) {
 389            $add .= ' user_from_this_loop="true"';
 390    }*/
 391    $shortcode = '[';
 392    $shortcode .= 'types usermeta="' . $field['slug'] . '"' . $add;
 393    $shortcode .= ']' . $content . '[/types]';
 394    $shortcode = apply_filters( 'wpcf_fields_shortcode', $shortcode, $field );
 395    $shortcode = apply_filters( 'wpcf_fields_shortcode_type_' . $field['type'],
 396            $shortcode, $field );
 397    $shortcode = apply_filters( 'wpcf_fields_shortcode_slug_' . $field['slug'],
 398            $shortcode, $field );
 399    return $shortcode;
 400}
 401
 402/**
 403 * Calls view function for specific usermeta field type.
 404 *
 405 * @param type $field
 406 * @param type $atts (additional attributes: user_id, user_name, user_is_author, user_current)
 407 * @return type
 408 */
 409function types_render_usermeta( $field_id, $params, $content = null, $code = '' ) {
 410
 411    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
 412    
 413    global $wpcf, $post, $wpdb, $WP_Views;
 414    // HTML var holds actual output
 415    $html = '';
 416    $current_user = wpcf_usermeta_get_user();
 417
 418    // Set post ID
 419    // user_id, user_name, user_is_author, user_current
 420    if ( is_object( $post ) ) {
 421        $post_id = $post->ID;
 422    } else {
 423        $post_id = 0;
 424    }
 425    if ( isset( $params['post_id'] ) && !empty( $params['post_id'] ) ) {
 426        $post_id = $params['post_id'];
 427    }
 428    
 429    //Get User id from views loop
 430    if ( isset($WP_Views->users_data['term']->ID) && !empty($WP_Views->users_data['term']->ID) ){
 431        $params['user_id'] = $WP_Views->users_data['term']->ID;
 432    }
 433    //print_r($params);exit;
 434    //Get user By ID
 435    if ( isset( $params['user_id'] ) ) {
 436        $user_id = $params['user_id'];
 437    } else if ( isset( $params['user_name'] ) ) { //Get user by login
 438        $user_id = $wpdb->get_var( "SELECT * FROM " . $wpdb->users . " WHERE user_login = '" . $params['user_name'] . "'",
 439                0, 0 );
 440    } else if ( isset( $params['user_is_author'] ) ) { //Get Post author
 441        $user_id = $post->post_author;
 442    } else if ( isset( $params['user_current'] ) ) {//Get current logged user
 443        $user_id = wpcf_usermeta_get_user();
 444    } else { //If empty get post author, if no post, return empty
 445        if ( !empty( $post_id ) ) {
 446            $user_id = $post->post_author;
 447        } else {
 448            return;
 449        }
 450    }
 451
 452    if ( empty( $user_id ) ) {
 453        return;
 454    }
 455    // Get field
 456    $field = wpcf_fields_get_field_by_slug( $field_id, 'wpcf-usermeta' );
 457
 458    
 459    // If field not found return empty string
 460    if ( empty( $field ) ) {
 461
 462        // Log
 463        if ( !function_exists( 'wplogger' ) ) {
 464            require_once WPCF_EMBEDDED_ABSPATH . '/common/wplogger.php';
 465        }
 466        global $wplogger;
 467        $wplogger->log( 'types_render_field call for missing field \''
 468                . $field_id . '\'', WPLOG_DEBUG );
 469
 470        return '';
 471    }
 472
 473    // See if repetitive
 474    if ( wpcf_admin_is_repetitive( $field ) ) {
 475
 476        $wpcf->usermeta_repeater->set( $user_id, $field );
 477        $_meta = $wpcf->usermeta_repeater->_get_meta();
 478        $meta = '';
 479        if ( isset( $_meta['custom_order'] ) ) {
 480            $meta = $_meta['custom_order'];
 481        }
 482
 483        if ( (count( $meta ) == 1 ) ) {
 484            $meta_id = key( $meta );
 485            $_temp = array_shift( $meta );
 486            if ( strval( $_temp ) == '' ) {
 487                return '';
 488            } else {
 489                $params['field_value'] = $_temp;
 490                return types_render_field_single( $field, $params, $content,
 491                                $code, $meta_id );
 492            }
 493        } else if ( !empty( $meta ) ) {
 494            $output = '';
 495
 496            if ( isset( $params['index'] ) ) {
 497                $index = $params['index'];
 498            } else {
 499                $index = '';
 500            }
 501
 502            // Allow wpv-for-each shortcode to set the index
 503            $index = apply_filters( 'wpv-for-each-index', $index );
 504
 505            if ( $index === '' ) {
 506                $output = array();
 507                foreach ( $meta as $temp_key => $temp_value ) {
 508                    $params['field_value'] = $temp_value;
 509                    $temp_output = types_render_field_single( $field, $params,
 510                            $content, $code, $temp_key );
 511                    if ( !empty( $temp_output ) ) {
 512                        $output[] = $temp_output;
 513                    }
 514                }
 515                if ( !empty( $output ) && isset( $params['separator'] ) ) {
 516                    $output = implode( html_entity_decode( $params['separator'] ),
 517                            $output );
 518                } else if ( !empty( $output ) ) {
 519                    $output = implode( '', $output );
 520                } else {
 521                    return '';
 522                }
 523            } else {
 524                // Make sure indexed right
 525                $_index = 0;
 526                foreach ( $meta as $temp_key => $temp_value ) {
 527                    if ( $_index == $index ) {
 528                        $params['field_value'] = $temp_value;
 529                        $output = types_render_field_single( $field, $params,
 530                                $content, $code, $temp_key );
 531                    }
 532                    $_index++;
 533                }
 534            }
 535            $html = $output;
 536        } else {
 537            return '';
 538        }
 539    } else {
 540        $params['field_value'] = get_user_meta( $user_id, wpcf_types_get_meta_prefix( $field ) . $field['slug'], true );
 541        if ( 'select-eye-color' == $params['usermeta'] ) {
 542        }
 543        /**
 544         * get default value for radio && select
 545         */
 546        if (
 547            '' == $params['field_value']
 548            && preg_match( '/^(radio|select)$/i', $field['type'] )
 549            && array_key_exists( 'default', $field['data']['options'] )
 550            && $field['data']['options']['default']
 551        ) {
 552            $params['field_value'] = $field['data']['options'][$field['data']['options']['default']]['value'];
 553        }
 554        if ( $params['field_value'] == '' && $field['type'] != 'checkbox' ) {
 555            return '';
 556        }
 557        $html = types_render_field_single( $field, $params, $content, $code );
 558    }
 559
 560    // API filter
 561    $wpcf->usermeta_field->set( $user_id, $field );
 562    return $wpcf->usermeta_field->html( $html, $params );
 563}
 564
 565/**
 566 * Calls view function for specific field type.
 567 *
 568 * @param type $field
 569 * @param type $atts
 570 * @return type
 571 */
 572function types_render_usermeta_field( $field_id, $params, $content = null,
 573        $code = '' ) {
 574
 575    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
 576    global $wpcf, $post;
 577
 578    // HTML var holds actual output
 579    $html = '';
 580
 581    // Set post ID
 582    $post_id = $post->ID;
 583    if ( isset( $params['post_id'] ) && !empty( $params['post_id'] ) ) {
 584        $post_id = $params['post_id'];
 585    }
 586
 587    // Get field
 588    $field = wpcf_fields_get_field_by_slug( $field_id, 'wpcf-usermeta' );
 589
 590    // If field not found return empty string
 591    if ( empty( $field ) ) {
 592
 593        // Log
 594        if ( !function_exists( 'wplogger' ) ) {
 595            require_once WPCF_EMBEDDED_ABSPATH . '/common/wplogger.php';
 596        }
 597        global $wplogger;
 598        $wplogger->log( 'types_render_usermeta_field call for missing field \''
 599                . $field_id . '\'', WPLOG_DEBUG );
 600
 601        return '';
 602    }
 603
 604    //Get user By ID
 605    if ( isset( $params['user_id'] ) ) {
 606        $user_id = $params['user_id'];
 607    } else if ( isset( $params['user_name'] ) ) { //Get user by login
 608        $user_id = $wpdb->get_var( "SELECT * FROM " . $wpdb->prefix . "users WHERE user_login = '" . $params['user_name'] . "'",
 609                0, 0 );
 610    } else if ( isset( $params['user_is_author'] ) ) { //Get Post author
 611        $user_id = $post->post_author;
 612    } else if ( isset( $params['user_current'] ) ) {//Get current logged user
 613        $user_id = wpcf_usermeta_get_user();
 614    } else { //If empty get post author, if no post, return empty
 615        if ( !empty( $post_id ) ) {
 616            $user_id = $post->post_author;
 617        } else {
 618            return;
 619        }
 620    }
 621
 622    if ( empty( $user_id ) ) {
 623        return;
 624    }
 625
 626    // Set field
 627    $wpcf->usermeta_field->set( $user_id, $field );
 628
 629
 630    // See if repetitive
 631    if ( wpcf_admin_is_repetitive( $field ) ) {
 632        $wpcf->usermeta_repeater->set( $user_id, $field );
 633        $_meta = $wpcf->usermeta_repeater->_get_meta();
 634        $meta = $_meta['custom_order'];
 635//        $meta = get_post_meta( $post_id,
 636//                wpcf_types_get_meta_prefix( $field ) . $field['slug'], false );
 637        // Sometimes if meta is empty - array(0 => '') is returned
 638        if ( (count( $meta ) == 1 ) ) {
 639            $meta_id = key( $meta );
 640            $_temp = array_shift( $meta );
 641            if ( strval( $_temp ) == '' ) {
 642                return '';
 643            } else {
 644
 645                $params['field_value'] = $_temp;
 646                return types_render_field_single( $field, $params, $content,
 647                                $code, $meta_id );
 648            }
 649        } else if ( !empty( $meta ) ) {
 650            $output = '';
 651
 652            if ( isset( $params['index'] ) ) {
 653                $index = $params['index'];
 654            } else {
 655                $index = '';
 656            }
 657
 658            // Allow wpv-for-each shortcode to set the index
 659            $index = apply_filters( 'wpv-for-each-index', $index );
 660
 661            if ( $index === '' ) {
 662                $output = array();
 663                foreach ( $meta as $temp_key => $temp_value ) {
 664                    $params['field_value'] = $temp_value;
 665                    $temp_output = types_render_field_single( $field, $params,
 666                            $content, $code, $temp_key );
 667                    if ( !empty( $temp_output ) ) {
 668                        $output[] = $temp_output;
 669                    }
 670                }
 671                if ( !empty( $output ) && isset( $params['separator'] ) ) {
 672                    $output = implode( html_entity_decode( $params['separator'] ),
 673                            $output );
 674                } else if ( !empty( $output ) ) {
 675                    $output = implode( '', $output );
 676                } else {
 677                    return '';
 678                }
 679            } else {
 680                // Make sure indexed right
 681                $_index = 0;
 682                foreach ( $meta as $temp_key => $temp_value ) {
 683                    if ( $_index == $index ) {
 684                        $params['field_value'] = $temp_value;
 685                        return types_render_field_single( $field, $params,
 686                                        $content, $code, $temp_key );
 687                    }
 688                    $_index++;
 689                }
 690                // If missed index
 691                return '';
 692            }
 693            $html = $output;
 694        } else {
 695            return '';
 696        }
 697    } else {
 698        $params['field_value'] = get_user_meta( $user_id,
 699                wpcf_types_get_meta_prefix( $field ) . $field['slug'], true );
 700        if ( $params['field_value'] == '' && $field['type'] != 'checkbox' ) {
 701            return '';
 702        }
 703        $html = types_render_field_single( $field, $params, $content, $code,
 704                $wpcf->usermeta_field->meta_object->umeta_id );
 705    }
 706
 707    // API filter
 708//    $wpcf->usermeta_field->set( $user_id, $field );
 709    return $wpcf->usermeta_field->html( $html, $params );
 710}
 711
 712/**
 713 * Add fields to user profile
 714 */
 715function wpcf_admin_user_profile_load_hook( $user ){
 716    if ( !current_user_can( 'edit_user', $user->ID ) )
 717        return false;
 718
 719    if ( !wpcf_is_embedded() ) {
 720        require_once WPCF_INC_ABSPATH . '/usermeta.php';
 721    }
 722    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
 723    require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta.php';
 724    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
 725    require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
 726    add_action( 'admin_footer', 'wpcf_admin_fields_usermeta_styles' );
 727
 728
 729    wpcf_admin_userprofile_init( $user );
 730}
 731
 732/**
 733 * Add styles to admin fields groups
 734 */
 735
 736add_action('admin_head-profile.php', 'wpcf_admin_fields_usermeta_styles' );
 737add_action('admin_head-user-edit.php', 'wpcf_admin_fields_usermeta_styles' );
 738add_action('admin_head-user-new.php', 'wpcf_admin_fields_usermeta_styles' );
 739
 740function wpcf_admin_fields_usermeta_styles(){
 741
 742    if ( !wpcf_is_embedded() ) {
 743        require_once WPCF_INC_ABSPATH . '/usermeta.php';
 744    }
 745    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
 746    require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta.php';
 747    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
 748    require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
 749    $groups = wpcf_admin_fields_get_groups( 'wp-types-user-group' );
 750    $content = '';
 751    if ( !empty( $groups ) ) {
 752        foreach ( $groups as $group ) {
 753            $content .= str_replace( "}", '}'.PHP_EOL, wpcf_admin_get_groups_admin_styles_by_group( $group['id'] ) );
 754            $content .= PHP_EOL;
 755        }
 756    }
 757    if ( $content ) {
 758        printf('<style type="text/css">%s</style>%s', $content, PHP_EOL );
 759    }
 760}
 761
 762/**
 763 * Add fields to user profile
 764 */
 765function wpcf_admin_user_profile_save_hook( $user_id ){
 766    if ( !current_user_can( 'edit_user', $user_id ) )
 767        return false;
 768
 769    if ( !wpcf_is_embedded() ) {
 770        require_once WPCF_INC_ABSPATH . '/usermeta.php';
 771    }
 772    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
 773    require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta.php';
 774    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
 775    require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
 776    wpcf_admin_userprofilesave_init( $user_id );
 777}
 778
 779/*
 780 *  Register Usermeta Groups in Types Access
 781 *
 782 *
 783 */
 784
 785class Usermeta_Access
 786{
 787
 788    public static $user_groups = '';
 789    
 790    /**
 791     * Initialize plugin enviroment
 792     */
 793    public function __construct() {
 794        // setup custom capabilities
 795        self::$user_groups = wpcf_admin_fields_get_groups('wp-types-user-group');
 796        //If access plugin installed
 797        if ( function_exists( 'wpcf_access_register_caps' ) ) { // integrate with Types Access
 798            if ( !empty( self::$user_groups ) ) {
 799                //Add Usermeta Fields area
 800                add_filter( 'types-access-area',
 801                        array('Usermeta_Access', 'register_access_usermeta_area'),
 802                        10, 2 );
 803                //Add Usermeta Fields groups
 804                add_filter( 'types-access-group',
 805                        array('Usermeta_Access', 'register_access_usermeta_groups'),
 806                        10, 2 );
 807                //Add Usermeta Fields caps to groups
 808                add_filter( 'types-access-cap',
 809                        array('Usermeta_Access', 'register_access_usermeta_caps'),
 810                        10, 3 );
 811            }
 812        }
 813    }
 814
 815    // register custom CRED Frontend capabilities specific to each group
 816    public static function register_access_usermeta_caps( $caps, $area_id,
 817            $group_id )
 818    {
 819        $USERMETA_ACCESS_AREA_NAME = __( 'User Meta Fields Frontend Access',
 820                'wpcf' );
 821        $USERMETA_ACCESS_AREA_ID = '__USERMETA_FIELDS';
 822        $default_role = 'guest'; //'administrator';
 823        //List of caps with default permissions
 824        $usermeta_caps = array(
 825           /* array('view_own_on_site', $default_role, __( 'View own fields on site',
 826                        'wpcf' )),
 827            array('view_others_on_site', $default_role, __( 'View others fields on site',
 828                        'wpcf' )),*/
 829            array('view_own_in_profile', $default_role, __( 'View own fields in profile',
 830                        'wpcf' )),
 831            array('modify_own', $default_role, __( 'Modify own fields', 'wpcf' )),
 832                /*
 833                  array('view_others_in_profile',$default_role,__('View others fields in profile','wpcf')),
 834                  array('modify_others_','administrator',__('Modify others fields','wpcf')), */
 835        );
 836        if ( $area_id == $USERMETA_ACCESS_AREA_ID ) {
 837            $fields_groups = wpcf_admin_fields_get_groups( 'wp-types-user-group' );
 838            if ( !empty( $fields_groups ) ) {
 839                foreach ( $fields_groups as $group ) {
 840                    $USERMETA_ACCESS_GROUP_NAME = $group['name'] . ' Access Group';
 841                    $USERMETA_ACCESS_GROUP_ID = '__USERMETA_FIELDS_GROUP_' . $group['slug'];
 842                    if ( $group_id == $USERMETA_ACCESS_GROUP_ID ) {
 843                        for ( $i = 0; $i < count( $usermeta_caps ); $i++ ) {
 844                            $caps[$usermeta_caps[$i][0] . '_' . $group['slug']] = array(
 845                                'cap_id' => $usermeta_caps[$i][0] . '_' . $group['slug'],
 846                                'title' => $usermeta_caps[$i][2],
 847                                'default_role' => $usermeta_caps[$i][1]
 848                            );
 849                        }
 850                    }
 851                }
 852            }
 853        }
 854
 855        return $caps;
 856    }
 857
 858    // register a new Types Access Group within Area for Usermeta Fields Groups Frontend capabilities
 859    public static function register_access_usermeta_groups( $groups, $id )
 860    {
 861        $USERMETA_ACCESS_AREA_NAME = __( 'User Meta Fields Frontend Access',
 862                'wpcf' );
 863        $USERMETA_ACCESS_AREA_ID = '__USERMETA_FIELDS';
 864
 865        if ( $id == $USERMETA_ACCESS_AREA_ID ) {
 866            $fields_groups = wpcf_admin_fields_get_groups( 'wp-types-user-group' );
 867            if ( !empty( $fields_groups ) ) {
 868                foreach ( $fields_groups as $group ) {
 869                    $USERMETA_ACCESS_GROUP_NAME = $group['name'];
 870                    //. ' User Meta Fields Access Group'
 871                    $USERMETA_ACCESS_GROUP_ID = '__USERMETA_FIELDS_GROUP_' . $group['slug'];
 872                    $groups[] = array('id' => $USERMETA_ACCESS_GROUP_ID, 'name' => '' . $USERMETA_ACCESS_GROUP_NAME);
 873                }
 874            }
 875        }
 876        return $groups;
 877    }
 878
 879    // register a new Types Access Area for Usermeta Fields Groups Frontend capabilities
 880    public static function register_access_usermeta_area( $areas,
 881            $area_type = 'usermeta' )
 882    {
 883        $USERMETA_ACCESS_AREA_NAME = __( 'User Meta Fields Access', 'wpcf' );
 884        $USERMETA_ACCESS_AREA_ID = '__USERMETA_FIELDS';
 885        $areas[] = array('id' => $USERMETA_ACCESS_AREA_ID, 'name' => $USERMETA_ACCESS_AREA_NAME);
 886        return $areas;
 887    }
 888
 889}
 890
 891/*
 892 *  Register Post Fields Groups in Types Access
 893 *
 894 * @author Gen gen.i@icanlocalize.com
 895 * @since Types 1.3
 896 */
 897
 898class Post_Fields_Access
 899{
 900
 901    /**
 902     * Initialize plugin enviroment
 903     */
 904    public static $fields_groups = '';
 905	
 906    public function __construct() {
 907    	//Get list of groups
 908    	self::$fields_groups = wpcf_admin_fields_get_groups();
 909        // setup custom capabilities
 910        //If access plugin installed
 911        if ( function_exists( 'wpcf_access_register_caps' ) ) { // integrate with Types Access
 912            if ( !empty( self::$fields_groups ) ) {
 913                //Add Fields area
 914                add_filter( 'types-access-area',
 915                        array('Post_Fields_Access', 'register_access_fields_area'),
 916                        10, 2 );
 917                //Add Fields groups
 918                add_filter( 'types-access-group',
 919                        array('Post_Fields_Access', 'register_access_fields_groups'),
 920                        10, 2 );
 921                
 922                //Add Fields caps to groups
 923                add_filter( 'types-access-cap',
 924                        array('Post_Fields_Access', 'register_access_fields_caps'),
 925                        10, 3 );
 926				//}		
 927            }
 928        }
 929    }
 930
 931    // register custom CRED Frontend capabilities specific to each group
 932    public static function register_access_fields_caps( $caps, $area_id,
 933            $group_id )
 934    {
 935        $FIELDS_ACCESS_AREA_NAME = __( 'Post Custom Fields Frontend Access',
 936                'wpcf' );
 937        $FIELDS_ACCESS_AREA_ID = '__FIELDS';
 938        $default_role = 'guest'; //'administrator';
 939        //List of caps with default permissions
 940        $fields_caps = array(
 941            /*array('view_fields_on_site', $default_role, __( 'View Fields On Site',
 942                        'wpcf' )),*/
 943            array('view_fields_in_edit_page', $default_role, __( 'View Fields In Edit Page',
 944                        'wpcf' )),
 945            array('modify_fields_in_edit_page', 'author', __( 'Modify Fields In Edit Page',
 946                        'wpcf' )),
 947        );
 948        if ( $area_id == $FIELDS_ACCESS_AREA_ID ) {
 949
 950            if ( !empty( self::$fields_groups ) ) {
 951                foreach ( self::$fields_groups as $group ) {
 952                    $FIELDS_ACCESS_GROUP_NAME = $group['name'] . ' Access Group';
 953                    $FIELDS_ACCESS_GROUP_ID = '__FIELDS_GROUP_' . $group['slug'];
 954                    if ( $group_id == $FIELDS_ACCESS_GROUP_ID ) {
 955                        for ( $i = 0; $i < count( $fields_caps ); $i++ ) {
 956                            $caps[$fields_caps[$i][0] . '_' . $group['slug']] = array(
 957                                'cap_id' => $fields_caps[$i][0] . '_' . $group['slug'],
 958                                'title' => $fields_caps[$i][2],
 959                                'default_role' => $fields_caps[$i][1]
 960                            );
 961                        }
 962                    }
 963                }
 964            }
 965        }
 966
 967        return $caps;
 968    }
 969
 970    // register a new Types Access Group within Area for Post Fields Groups Frontend capabilities
 971    public static function register_access_fields_groups( $groups, $id )
 972    {
 973        $FIELDS_ACCESS_AREA_NAME = __( 'Post Fields Frontend Access', 'wpcf' );
 974        $FIELDS_ACCESS_AREA_ID = '__FIELDS';
 975		
 976        if ( $id == $FIELDS_ACCESS_AREA_ID ) {
 977            if ( !empty( self::$fields_groups ) ) {
 978                foreach ( self::$fields_groups as $group ) {
 979                    $FIELDS_ACCESS_GROUP_NAME = $group['name'];
 980                    //. ' User Meta Fields Access Group'
 981                    $FIELDS_ACCESS_GROUP_ID = '__FIELDS_GROUP_' . $group['slug'];
 982                    $groups[] = array('id' => $FIELDS_ACCESS_GROUP_ID, 'name' => '' . $FIELDS_ACCESS_GROUP_NAME);
 983                }
 984            }
 985        }
 986        return $groups;
 987    }
 988
 989    // register a new Types Access Area for Post Fields Groups Frontend capabilities
 990    public static function register_access_fields_area( $areas,
 991            $area_type = 'usermeta' )
 992    {
 993        $FIELDS_ACCESS_AREA_NAME = __( 'Post Meta Fields Access', 'wpcf' );
 994        $FIELDS_ACCESS_AREA_ID = '__FIELDS';
 995        $areas[] = array('id' => $FIELDS_ACCESS_AREA_ID, 'name' => $FIELDS_ACCESS_AREA_NAME);
 996        return $areas;
 997    }
 998
 999}
1000
1001add_action( 'wp_ajax_wpcf_types_suggest_user',
1002        'wpcf_access_wpcf_types_suggest_user_ajax' );
1003
1004/**
1005 * Suggest user AJAX.
1006 */
1007function wpcf_access_wpcf_types_suggest_user_ajax()
1008{
1009    global $wpdb;
1010    $users = '';
1011    $q = wptoolset_esc_like(esc_sql( trim( $_GET['q'] ) ));
1012    $found = $wpdb->get_results( "SELECT ID, display_name, user_login FROM $wpdb->users WHERE user_nicename LIKE '%%$q%%' OR user_login LIKE '%%$q%%' OR display_name LIKE '%%$q%%' OR user_email LIKE '%%$q%%' LIMIT 10" );
1013
1014    if ( !empty( $found ) ) {
1015        foreach ( $found as $user ) {
1016            $users .= '<li>' . $user->user_login . '</li>';
1017        }
1018    }
1019    echo $users;
1020    die();
1021}
1022
1023/*
1024 * Callback sumit form usermeta addon
1025 */
1026
1027function wpcf_get_usermeta_form_addon_submit( $views_usermeta = false ){
1028    $add = '';
1029    if ( !empty( $_POST['is_usermeta'] ) ) {
1030        if ( $_POST['display_username_for'] == 'post_autor' ) {
1031            $add .= ' user_is_author="true"';
1032        } elseif ( $_POST['display_username_for'] == 'current_user' ) {
1033            $add .= ' user_current="true"';
1034        }
1035         else {
1036            if ( $_POST['display_username_for_suser_selector'] == 'specific_user_by_id' ) {
1037                $add .= ' user_id="' . $_POST['display_username_for_suser_id_value'] . '"';
1038            } else {
1039                $add .= ' user_name="' . $_POST['display_username_for_suser_username_value'] . '"';
1040            }
1041        }
1042    }
1043    return $add;
1044}
1045
1046/*
1047 * Usermeta fields addon.
1048 * Add form user users
1049*/
1050
1051function wpcf_get_usermeta_form_addon( $settings = array() ){
1052	global $wpdb;
1053	$form = array();
1054	$users = $wpdb->get_results("SELECT ID, user_login, display_name FROM $wpdb->users LIMIT 5");
1055	$form[] = array(
1056		'#type' => 'hidden',
1057		'#value' => 'true',
1058        '#name' => 'is_usermeta',
1059	);
1060	$__default = 'post_autor';
1061	$form[] = array(
1062		'#type' => 'radio',
1063		'#before' => '<div class="fieldset"><p class="form-inline">',
1064		'#suffix' => '</p>',
1065		'#value' => 'post_autor',
1066		'#title' => 'Author of this post',
1067        '#name' => 'display_username_for',
1068		'#default_value' => isset( $settings['user_is_author'] ) && $settings['user_is_author'] == 'true' ? 'post_autor' : $__default,
1069        '#inline' => true,
1070		'#attributes' => array('onclick' => 'wpcf_showmore(false)')
1071	);
1072	$form[] = array(
1073		'#type' => 'radio',
1074		'#before' => '<p class="form-inline">',
1075		'#suffix' => '</p>',
1076		'#value' => 'current_user',
1077		'#title' => 'The current logged in user',
1078        '#name' => 'display_username_for',
1079		'#default_value' => isset( $settings['user_current'] ) && $settings['user_current'] == 'true' ? 'current_user' : $__default,
1080        '#inline' => true,
1081		'#attributes' => array('onclick' => 'wpcf_showmore(false)')
1082	);
1083	$form[] = array(
1084		'#type' => 'radio',
1085		'#before' => '<p class="form-inline">',
1086		'#suffix' => '</p>',
1087		'#title' => 'A specific user',
1088		'#value' => 'pecific_user',
1089		'#id' => 'display_username_for_suser',
1090        '#name' => 'display_username_for',
1091		'#default_value' => isset( $settings['user_id'] ) || isset( $settings['user_name'] ) ? 'pecific_user' : $__default,
1092		'#after' => '',
1093        '#inline' => true,
1094		'#attributes' => array('onclick' => 'wpcf_showmore(true)')
1095	);
1096    $__username = isset( $settings['user_name'] ) ? $settings['user_name'] : '';
1097    $__userid = isset( $settings['user_id'] ) ? intval( $settings['user_id'] ) : '';
1098    $__hidden = !isset( $settings['user_id'] ) && !isset( $settings['user_name'] ) ? ' style="display:none;"' : '';
1099    $__hiddenId = !isset( $settings['user_id'] ) && isset( $settings['user_name'] ) ? ' style="display:none;"' : '';
1100	$form[] = array(
1101		'#type' => 'radio',
1102		'#title' => 'User ID',
1103		'#value' => 'specific_user_by_id',
1104		'#id' => 'display_username_for_suser_id',
1105        '#name' => 'display_username_for_suser_selector',
1106		'#before' => '<div class="group-nested form-inline" id="specific_user_div"' . $__hidden . '><p>',
1107		'#after' => '<input type="text" class="wpcf-form-textfield form-textfield textfield" name="display_username_for_suser_id_value" value="' . $__userid . '"'.
1108		' id="display_username_for_suser_id_value" value=""' . $__hiddenId . '></p>',
1109		'#default_value' => isset( $settings['user_id'] ) || !isset( $settings['user_name'] ) ? 'specific_user_by_id' : '',
1110        '#inline' => true,
1111		'#attributes' => array('onclick' => 'hideControls(\'display_username_for_suser_username_value\',\'display_username_for_suser_id_value\')')
1112	);
1113	$dropdown_users = '';
1114	foreach ($users as $u) {
1115        $dropdown_users .= '<option value="' . $u->user_login . '">' . $u->display_name . ' (' . $u->user_login . ')' . '</option>';
1116    }
1117    $__hidden = !isset( $settings['user_name'] ) ? ' style="display:none;"' : '';
1118	$form[] = array(
1119		'#type' => 'radio',
1120		'#title' => 'User name',
1121		'#value' => 'specific_user_by_username',
1122		'#id' => 'display_username_for_suser_username',
1123        '#name' => 'display_username_for_suser_selector',
1124		'#before' => '<p class="types-suggest-user types-suggest" id="types-suggest-user">',
1125		'#after' => '<input type="text" class="input wpcf-form-textfield form-textfield textfield"'. $__hidden .
1126		' name="display_username_for_suser_username_value" id="display_username_for_suser_username_value" value="' . $__username . '"></p></div></div>',
1127		'#default_value' => isset( $settings['user_name'] ) ? 'specific_user_by_username' : '',
1128        '#inline' => true,
1129		'#attributes' => array('onclick' => 'hideControls(\'display_username_for_suser_id_value\',\'display_username_for_suser_username_value\')')
1130	);
1131
1132	return $form;
1133}
1134
1135add_action('load-user-new.php', 'wpcf_usermeta_add_user_screen');
1136function wpcf_usermeta_add_user_screen() {
1137    require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-add-user.php';
1138    wpcf_usermeta_add_user_screen_init();
1139}