Plugin Directory

source: wp-members/trunk/includes/class-wp-members-user-profile.php

Last change on this file was 3199979, checked in by cbutlerjr, 5 months ago

3.5.0 beta rc 2 release

File size: 22.3 KB
Line 
1<?php
2/**
3 * The WP_Members User Profile Class.
4 *
5 * @package WP-Members
6 * @subpackage WP_Members Admin User Profile Object Class
7 * @since 3.1.8
8 */
9
10// Exit if accessed directly.
11if ( ! defined( 'ABSPATH' ) ) {
12        exit();
13}
14
15class WP_Members_User_Profile {
16       
17        /**
18         * Remove "admin only" fields if dashboard user profile.
19         *
20         * @since 3.3.6
21         *
22         * @param  string  $tag
23         * @return array   $fields
24         */
25        static function get_fields( $tag ) {
26                $fields = wpmem_fields( $tag );
27                /**
28                 * Filters the required capability for dashboard profile.
29                 *
30                 * @since 3.5.0
31                 *
32                 * @param  string  $required_capability
33                 */
34                $required_capability = apply_filters( 'wpmem_user_profile_caps', 'edit_users' );
35                if ( 'profile_dashboard' == $tag && false == current_user_can( $required_capability ) ) {
36                        foreach( $fields as $key => $field ) {
37                                if ( false == $field['profile'] ) {
38                                        unset( $fields[ $key ] );
39                                }
40                        }
41                }
42                return $fields;
43        }
44       
45        /**
46         * Static function to display WP-Members fields on the admin/dashboard user profile.
47         *
48         * Function was created in 3.1.9 as a merge of wpmem_admin_fields()
49         * and wpmem_user_profile().
50         *
51         * @since 3.1.9
52         *
53         * @global object $current_screen
54         * @global string $user_ID
55         * @global object $wpmem
56         * @param  object $user_obj
57         */
58        static function profile( $user_obj ) {
59       
60                global $current_screen, $user_ID, $wpmem;
61
62                /** This filter is documented in includes/class-wp-members-user-profile.php */
63                $required_capability = apply_filters( 'wpmem_user_profile_caps', 'edit_users' );
64
65                $user_id = ( 'profile' == $current_screen->id ) ? $user_ID : filter_var( $_REQUEST['user_id'], FILTER_SANITIZE_NUMBER_INT ); 
66                $display = ( 'profile' == $current_screen->base ) ? 'user' : 'admin'; 
67                $display = ( current_user_can( $required_capability ) ) ? 'admin' : $display;
68                $heading = ( 'admin' == $display ) ? __( 'WP-Members Additional Fields', 'wp-members' ) : __( 'Additional Information', 'wp-members' );
69               
70                /**
71                 * Filter the heading for additional profile fields.
72                 *
73                 * Filter is applied for the admin user edit ("wpmem_admin_profile_heading")
74                 * and the user profile edit ("wpmem_user_profile_heading").
75                 *
76                 * @since 2.8.2 Admin Profile
77                 * @since 2.9.1 Dashboard Profile
78                 * @since 3.1.9 Merged admin/dashboard profile
79                 *
80                 * @param string The default additional fields heading.
81                 */
82                $heading = apply_filters( 'wpmem_' . $display . '_profile_heading', $heading ); ?>
83                <h3><?php echo esc_html( $heading ); ?></h3>   
84                <table class="form-table">
85                        <?php
86                        // Get fields.
87                        // $wpmem_fields = ( 'admin' == $display ) ? self::get_fields( 'profile_admin' ) : self::get_fields( 'profile_dashboard' );
88                        $wpmem_fields = ( 'admin' == $display ) ? self::get_fields( 'all' ) : self::get_fields( 'profile' );
89                        // Get excluded meta.
90                        $exclude = wpmem_get_excluded_meta( $display . '-profile' );
91               
92                        // If tos is an active field.
93                        if ( isset( $wpmem_fields['tos'] ) ) {
94                                if (  1 != $wpmem_fields['tos']['register'] ) {
95                                        unset( $wpmem_fields['tos'] );
96                                }
97                                // This is the dashboard profile, and user has current field value.
98                                if ( 'user' == $display
99                                        && isset( $wpmem_fields['tos'] )
100                                        && ( get_user_meta( $user_ID, 'tos', true ) == $wpmem_fields['tos']['checked_value'] ) ) {
101                                        unset( $wpmem_fields['tos'] );
102                                }
103                        }
104
105                        /**
106                         * Fires at the beginning of generating the WP-Members fields in the user profile.
107                         *
108                         * Action fires for the admin user edit ("wpmem_admin_before_profile")
109                         * and the user profile edit ("wpmem_user_before_profile").
110                         *
111                         * @since 2.9.3 Created for admin profile.
112                         * @since 3.1.9 Added to dashboard profile.
113                         *
114                         * @param int   $user_id      The user's ID.
115                         * @param array $wpmem_fields The WP-Members fields.
116                         */
117                        do_action( 'wpmem_' . $display . '_before_profile', $user_id, $wpmem_fields );
118
119                        // Assemble form rows array.
120                        $rows = array();
121                        foreach ( $wpmem_fields as $meta => $field ) {
122
123                                $valtochk = ''; $values = '';
124
125                                // Determine which fields to show in the additional fields area.
126                                $show = ( ! $field['native'] && ! in_array( $meta, $exclude ) ) ? true : false;
127                                //$show = ( 'tos' == $meta && $field['register'] ) ? null : $show;
128
129                                if ( $show ) {
130
131                                        $val = get_user_meta( $user_id, $meta, true );
132                                        $val = ( $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' ) ? $val : htmlspecialchars( $val );
133                                        if ( $field['type'] == 'checkbox' ) {
134                                                $valtochk = $val;
135                                                $val = $field['checked_value'];
136                                        }
137
138                                        if ( 'multicheckbox' == $field['type'] || 'select' == $field['type'] || 'multiselect' == $field['type'] || 'radio' == $field['type'] ) {
139                                                $values = $field['values'];
140                                                $valtochk = $val;
141                                        }
142
143                                        // Is this an image or a file?
144                                        if ( 'file' == $field['type'] || 'image' == $field['type'] ) {
145                                                $empty_file = '<span class="description">' . esc_html__( 'None' ) . '</span>';
146                                                if ( 'file' == $field['type'] ) {
147                                                        $attachment_url = wp_get_attachment_url( $val );
148                                                        $input = ( $attachment_url ) ? '<a href="' . esc_url( $attachment_url ) . '">' . esc_url_raw( $attachment_url ) . '</a>' : $empty_file;
149                                                } else {
150                                                        $attachment_url = wp_get_attachment_image( $val, 'medium' );
151                                                        if ( 'admin' == $display ) {
152                                                                $edit_url = admin_url( 'upload.php?item=' . $val );
153                                                                $input = ( $attachment_url ) ? '<a href="' . esc_url( $edit_url ) . '">' . esc_url_raw( $attachment_url ) . '</a>' : $empty_file;
154                                                        } else {
155                                                                $input = ( $attachment_url ) ? esc_url_raw( $attachment_url ) : $empty_file;
156                                                        }
157                                                }
158                                                $input.= '<br />' . wpmem_get_text( 'profile_upload' ) . '<br />';
159                                                $input.= wpmem_form_field( array(
160                                                        'name'    => $meta, 
161                                                        'type'    => $field['type'], 
162                                                        'value'   => $val, 
163                                                        'compare' => $valtochk,
164                                                ) );
165                                        } else {
166                                                if ( 'select' == $field['type'] || 'radio' == $field['type'] ) {
167                                                        $input = wpmem_form_field( $meta, $field['type'], $values, $valtochk );
168                                                } elseif( 'multicheckbox' == $field['type'] || 'multiselect' == $field['type'] ) {
169                                                        $input = wpmem_form_field( array( 'name'=>$meta, 'type'=>$field['type'], 'value'=>$values, 'compare'=>$valtochk, 'delimiter'=>$field['delimiter'] ) );
170                                                } else {
171                                                        $field['type'] = ( 'hidden' == $field['type'] ) ? 'text' : $field['type'];
172                                                       
173                                                        $formfield_args = array( 
174                                                                'name'     => $meta,
175                                                                'type'     => $field['type'],
176                                                                'value'    => $val,
177                                                                'compare'  => $valtochk,
178                                                                'required' => $field['required'],
179                                                                'class'    => 'regular-text',
180                                                                'placeholder' => ( isset( $field['placeholder'] ) ) ? $field['placeholder'] : '',
181                                                                'pattern'     => ( isset( $field['pattern']     ) ) ? $field['pattern']     : false,
182                                                                'title'       => ( isset( $field['title']       ) ) ? $field['title']       : false,
183                                                                'min'         => ( isset( $field['min']         ) ) ? $field['min']         : false,
184                                                                'max'         => ( isset( $field['max']         ) ) ? $field['max']         : false,
185                                                                'rows'        => ( isset( $field['rows']        ) ) ? $field['rows']        : false,
186                                                                'cols'        => ( isset( $field['cols']        ) ) ? $field['cols']        : false,
187                                                        );     
188                                               
189                                                        $input = wpmem_form_field( $formfield_args );
190                                                }
191                                        }
192
193                                        // Is the field required?
194                                        $req = ( $field['required'] ) ? ' <span class="description">' . esc_html__( '(required)' ) . '</span>' : '';
195                                        $label = '<label>' . esc_html__( $field['label'], 'wp-members' ) . $req . '</label>';
196
197                                        // Build the form rows for filtering.
198                                        $rows[ $meta ] = array(
199                                                'meta'         => $meta,
200                                                'type'         => $field['type'],
201                                                'value'        => $val,
202                                                'values'       => $values,
203                                                'label_text'   => esc_html__( $field['label'], 'wp-members' ),
204                                                'row_before'   => '<tr>',
205                                                'label'        => '<th>' . $label . '</th>',
206                                                'field_before' => '<td>',
207                                                'field'        => $input,
208                                                'field_after'  => '</td>',
209                                                'row_after'    => '</tr>',
210                                        );
211                                }
212                        }
213
214                        /**
215                         * Filter for rows.
216                         *
217                         * Filter is applied for the admin user edit ("wpmem_register_form_rows_admin")
218                         * and the user profile edit ("wpmem_register_form_rows_user").
219                         *
220                         * @since 3.1.0
221                         * @since 3.1.6 Deprecated $order.
222                         *
223                         * @param array  $rows {
224                         *     An array of the profile rows.
225                         *
226                         *     @type string $meta         The meta key.
227                         *     @type string $type         The field type.
228                         *     @type string $value        Value if set.
229                         *     @type string $values       Possible values (select, multiselect, multicheckbox, radio).
230                         *     @type string $label_text   Raw label text (no HTML).
231                         *     @type string $row_before   HTML before the row.
232                         *     @type string $label        HTML label.
233                         *     @type string $field_before HTML before the field input tag.
234                         *     @type string $field        HTML for field input.
235                         *     @type string $field_after  HTML after the field.
236                         *     @type string $row_after    HTML after the row.
237                         * }
238                         * @param string $tag adminprofile|userprofile
239                         */
240                        $rows = apply_filters( 'wpmem_register_form_rows_' . $display, $rows, $display . 'profile' );
241
242                        // Handle form rows display from array.
243                        foreach ( $rows as $row ) {
244                                $show_field =
245                                        $row['row_before'] . 
246                                                $row['label'] .
247                                                $row['field_before'] . $row['field'] . $row['field_after'] .
248                                        $row['row_after'];
249
250                                /**
251                                 * Filter the profile field.
252                                 *
253                                 * Filter is applied for the admin user edit ("wpmem_admin_profile_field")
254                                 * and the user profile edit ("wpmem_user_profile_field").
255                                 *
256                                 * @since 2.8.2
257                                 * @since 3.1.1 Added $user_id and $row
258                                 *
259                                 * @param string $show_field The HTML string for the additional profile field.
260                                 * @param string $user_id
261                                 * @param array  $row
262                                 */
263                                echo apply_filters( 'wpmem_' . $display . '_profile_field', $show_field, $user_id, $row );
264                        }
265
266                        /**
267                         * Fires after generating the WP-Members fields in the user profile.
268                         *
269                         * Action fires for the admin user edit ("wpmem_admin_after_profile")
270                         * and the user profile edit ("wpmem_user_after_profile").
271                         *
272                         * @since 2.9.3
273                         *
274                         * @param int   $user_id      The user's ID.
275                         * @param array $wpmem_fields The WP-Members fields.
276                         */
277                        do_action( 'wpmem_' . $display . '_after_profile', $user_id, $wpmem_fields ); ?>
278
279                </table><?php
280               
281                /**
282                 * Fires after the user profile table.
283                 *
284                 * Action fires for the admin user edit ("wpmem_admin_after_profile_table")
285                 * and the user profile edit ("wpmem_user_after_profile_table").
286                 *
287                 * @since 3.2.6
288                 *
289                 * @param int   $user_id      The user's ID.
290                 * @param array $wpmem_fields The WP-Members fields.
291                 */
292                do_action( 'wpmem_' . $display . '_after_profile_table', $user_id, $wpmem_fields );
293               
294        }
295       
296        /**
297         * Static function to update admin/dashboard user profile.
298         *
299         * Function was created in 3.1.9 as a merge of wpmem_admin_update()
300         * and wpmem_profile_update().
301         *
302         * @since 3.1.9
303         *
304         * @global object $current_screen
305         * @global string $user_id
306         * @global object $wpmem
307         * @param  string $user_id
308         * @return
309         */
310        static function update( $user_id ) {
311
312                // Prevent from firing on front end use (i.e. password reset).
313                if ( ! is_admin() ) {
314                        return;
315                }
316               
317                global $current_screen, $user_id, $wpmem;
318                // @todo Check this as a possible inclusion for front-end use.
319                $display = ( ! isset( $current_screen ) || is_null( $current_screen ) || 'profile' == $current_screen->base ) ? 'user' : 'admin';
320       
321                if ( ! $user_id ) {
322                        $user_id = filter_var( wpmem_get( 'user_id', -1, 'request' ), FILTER_SANITIZE_NUMBER_INT );
323                        if ( 1 > $user_id ) {
324                        // Still no user id? User cannot be updated.
325                        return;
326                        }
327                }
328
329                // $wpmem_fields = ( 'admin' == $display ) ? self::get_fields( 'profile_admin' ) : self::get_fields( 'profile_dashboard' );
330                $wpmem_fields = ( 'admin' == $display ) ? self::get_fields( 'all' ) : self::get_fields( 'profile' );
331       
332                // Check for password field before exclusions, just in case we are activating a user (otherwise password is removed on user/admin profiles).
333                $chk_pass = ( array_key_exists( 'password', $wpmem_fields ) && true === $wpmem_fields['password']['register'] ) ? true : false;
334       
335                $exclude = wpmem_get_excluded_meta( $display . '-profile' );
336
337                foreach ( $exclude as $excluded ) {
338                        unset( $wpmem_fields[ $excluded ] );
339                }
340
341                // If tos is an active field, this is the dashboard profile, and user has current field value.
342                if ( isset( $wpmem_fields['tos'] ) 
343                        && 'user' == $display 
344                        && get_user_meta( $user_id, 'tos', true ) == $wpmem_fields['tos']['checked_value'] ) {
345                        unset( $wpmem_fields['tos'] );
346                }
347
348                /**
349                 * Fires before the user profile is updated.
350                 *
351                 * Action fires for the admin user edit ("wpmem_admin_pre_user_update")
352                 * and the user profile edit ("wpmem_user_pre_user_update").
353                 *
354                 * @since 2.9.2 Added for admin profile update.
355                 * @since 3.1.9 Added for user profile update.
356                 *
357                 * @param int   $user_id      The user ID.
358                 * @param array $wpmem_fields Array of the custom fields.
359                 */
360                do_action( 'wpmem_' . $display . '_pre_user_update', $user_id, $wpmem_fields );
361
362                $fields = array();
363                $chk = false;
364                foreach ( $wpmem_fields as $meta => $field ) {
365                        if ( ! $field['native']
366                                && $field['type'] != 'password' 
367                                && $field['type'] != 'checkbox' 
368                                && $field['type'] != 'multiselect' 
369                                && $field['type'] != 'multicheckbox' 
370                                && $field['type'] != 'file' 
371                                && $field['type'] != 'image'
372                            && $field['type'] != 'textarea' ) {
373                                ( isset( $_POST[ $meta ] ) && 'password' != $field['type'] ) ? $fields[ $meta ] = sanitize_text_field( $_POST[ $meta ] ) : false;
374                               
375                                // For user profile (not admin).
376                                if ( 'admin' != $display ) {
377                                        // Check for required fields.
378                                        if ( ! $field['required'] ) {
379                                                $chk = true;
380                                        }
381                                        if ( $field['required'] && $_POST[ $meta ] != '' ) {
382                                                $chk = true;
383                                        }
384                                }
385                        } elseif ( $field['type'] == 'checkbox' ) {
386                                $fields[ $meta ] = wpmem_get_sanitized( $meta, '' ); // ( isset( $_POST[ $meta ] ) ) ? sanitize_text_field( $_POST[ $meta ] ) : '';
387                        } elseif ( $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' ) {
388                                $fields[ $meta ] = ( isset( $_POST[ $meta ] ) ) ? implode( $field['delimiter'], wp_unslash( $_POST[ $meta ] ) ) : '';
389                        } elseif ( $field['type'] == 'textarea' ) {
390                                $fields[ $meta ] = wpmem_get_sanitized( $meta, '', 'post', 'textarea' ); // ( isset( $_POST[ $meta ] ) ) ? sanitize_textarea_field( $_POST[ $meta ] ) : '';
391                        }
392                }
393
394                /**
395                 * Filter the submitted field values for backend profile update.
396                 *
397                 * Filters is applied for the admin user edit ("wpmem_admin_profile_update")
398                 * and the user profile edit ("wpmem_user_profile_update").
399                 *
400                 * @since 2.8.2 Added for Admin profile update.
401                 * @since 3.1.9 Added for User profile update.
402                 *
403                 * @param array $fields An array of the posted form values.
404                 * @param int   $user_id The ID of the user being updated.
405                 */
406                $fields = apply_filters( 'wpmem_' . $display . '_profile_update', $fields, $user_id );
407
408                // Handle meta update, skip excluded fields.
409                foreach ( $fields as $key => $val ) {
410                        if ( ! in_array( $key, $exclude ) ) {
411                                if ( ( 'admin' != $display && true == $chk ) || 'admin' == $display ) {
412                                        update_user_meta( $user_id, $key, $val );
413                                }
414                        }
415                }
416
417                if ( ! empty( $_FILES ) ) {
418                        $wpmem->user->upload_user_files( $user_id, $wpmem->fields );
419                }       
420
421                /** This filter is documented in includes/class-wp-members-user-profile.php */
422                $required_capability = apply_filters( 'wpmem_user_profile_caps', 'edit_users' );
423
424                if ( 'admin' == $display || current_user_can( $required_capability ) ) {
425                        if ( $wpmem->mod_reg == 1 ) {
426
427                                $wpmem_activate_user = ( isset( $_POST['activate_user'] ) == '' ) ? -1 : intval( $_POST['activate_user'] );
428
429                                if ( $wpmem_activate_user == 1 ) {
430                                        wpmem_activate_user( $user_id );
431                                } elseif ( $wpmem_activate_user == 0 ) {
432                                        wpmem_deactivate_user( $user_id );
433                                }
434                        }
435
436                        if ( defined( 'WPMEM_EXP_MODULE' ) && $wpmem->use_exp == 1 ) {
437                                if ( function_exists( 'wpmem_a_extenduser' ) ) {
438                                        wpmem_a_extenduser( $user_id );
439                                }
440                        }
441                       
442                        if ( wpmem_is_enabled( 'enable_products' ) ) {
443                                // Update products.
444                                foreach ( wpmem_get_sanitized( '_wpmem_membership_product', array(), 'post', 'array' ) as $product_key => $product_value ) {
445                                        // Sanitize.
446                                        $product_key = sanitize_text_field( $product_key );
447                                        // Enable or Disable?
448                                        if ( 'enable' == $product_value ) {
449                                                // Does product require a role?
450                                                if ( false != wpmem_get_membership_role( $product_key ) || '' != wpmem_get_membership_role( $product_key ) ) {
451                                                        wpmem_update_user_role( $user_id, wpmem_get_membership_role( $product_key ), 'add' );
452                                                }
453                                                // Do we need to set a specific date?
454                                                if ( isset( $_POST[ '_wpmem_membership_expiration_' . $product_key ] ) ) {
455                                                        wpmem_set_user_product( $product_key, $user_id, sanitize_text_field( $_POST[ '_wpmem_membership_expiration_' . $product_key ] ) );
456                                                } else {
457                                                        wpmem_set_user_product( $product_key, $user_id );
458                                                }
459                                        }
460                                        if ( 'disable' == $product_value ) {
461                                                $wpmem->user->remove_user_product( $product_key, $user_id );
462                                        }
463                                }
464                        }
465                }
466
467                /**
468                 * Fires after the user profile is updated.
469                 *
470                 * Action fires for the admin user edit ("wpmem_admin_after_user_update")
471                 * and the user profile edit ("wpmem_user_after_user_update").
472                 *
473                 * @since 2.9.2
474                 *
475                 * @param int $user_id The user ID.
476                 */
477                do_action( 'wpmem_' . $display . '_after_user_update', $user_id );
478
479                return;
480        }
481       
482        /**
483         * Sets user profile update to multipart form data.
484         *
485         * If the fields array has a file or image field, this will echo the
486         * necessary "multipart/form-data" enctype for the form tag.
487         *
488         * @since 3.1.8 (as wpmem_profile_multipart()).
489         * @since 3.1.9 Moved to User Profile object.
490         */
491        public static function add_multipart() {
492                $has_file = false;
493                foreach ( wpmem_fields() as $field ) {
494                        if ( $field['type'] == 'file' || $field['type'] == 'image' ) {
495                                $has_file = true;
496                                break;
497                        }
498                }
499                echo ( $has_file ) ? " enctype=\"multipart/form-data\"" : '';
500        }
501       
502        /**
503         * Adds user activation to the user profile.
504         *
505         * @since 3.1.1
506         * @since 3.2.0 Moved to WP_Members_User_Profile object
507         *
508         * @global object $wpmem
509         * @param  int    $user_id
510         */
511        public static function _show_activate( $user_id ) {
512                global $wpmem;
513
514                /** This filter is documented in includes/class-wp-members-user-profile.php */
515                $required_capability = apply_filters( 'wpmem_user_profile_caps', 'edit_users' );
516               
517                // See if reg is moderated, and if the user has been activated.
518                if ( $wpmem->mod_reg == 1 ) {
519                        // Make sure this isn't an admin looking at their own profile.
520                        if ( current_user_can( $required_capability ) && $user_id != get_current_user_id() ) {
521                                $user_active_flag = get_user_meta( $user_id, 'active', true );
522                                switch( $user_active_flag ) {
523
524                                        case "0":
525                                                $label  = __( 'Reactivate this user?', 'wp-members' );
526                                                $action = 1;
527                                                break;
528
529                                        case "1":
530                                                $label  = __( 'Deactivate this user?', 'wp-members' );
531                                                $action = 0;
532                                                break;
533
534                                        default:
535                                                $label  = __( 'Activate this user?', 'wp-members' );
536                                                $action = 1;
537                                                break;
538                                } 
539                                // Values used below are either already escaped or specifically defined (not variable input). ?>
540                                <tr>
541                                        <th><label><?php echo esc_html( $label ); ?></label></th>
542                                        <td><input id="activate_user" type="checkbox" class="input" name="activate_user" value="<?php echo intval( $action ); ?>" /></td>
543                                </tr>
544                        <?php }
545                }
546        }
547
548        /**
549         * Adds user expiration to the user profile.
550         *
551         * @since 3.1.1
552         * @since 3.2.0 Moved to WP_Members_User_Profile object
553         *
554         * @global object $wpmem
555         * @param  int    $user_id
556         */
557        public static function _show_expiration( $user_id ) {
558
559        global $wpmem;
560                /*
561                 * If using subscription model, show expiration.
562                 * If registration is moderated, this doesn't show
563                 * if user is not active yet.
564                 */
565                if ( defined( 'WPMEM_EXP_MODULE' ) && $wpmem->use_exp == 1 ) {
566                        if ( ( $wpmem->mod_reg == 1 &&  get_user_meta( $user_id, 'active', true ) == 1 ) || ( $wpmem->mod_reg != 1 ) ) {
567                                if ( function_exists( 'wpmem_a_extend_user' ) ) {
568                                        wpmem_a_extend_user( $user_id );
569                                }
570                        }
571                } 
572        } 
573
574
575        /**
576         * Adds user registration IP to the user profile.
577         *
578         * @since 3.1.1
579         * @since 3.2.0 Moved to WP_Members_User_Profile object
580         *
581         * @param  int    $user_id
582         */
583        public static function _show_ip( $user_id ) { ?>
584                <tr>
585                        <th><label><?php esc_html_e( 'IP @ registration', 'wp-members' ); ?></label></th>
586                        <td><?php echo esc_attr( get_user_meta( $user_id, 'wpmem_reg_ip', true ) ); ?></td>
587                </tr>
588                <?php
589        }
590
591        /**
592         * Add jquery ui tabs to user profile.
593         *
594         * @since 3.2.5
595         *
596         * @param int $user_id
597         */
598        static function _profile_tabs( $user_id ) {
599
600                /** This filter is documented in includes/class-wp-members-user-profile.php */
601                $required_capability = apply_filters( 'wpmem_user_profile_caps', 'edit_users' );
602               
603                if ( current_user_can( $required_capability ) ) {
604
605                        /**
606                         * Add tabs to user profile tabs.
607                         *
608                         * @since 3.2.5
609                         *
610                         * @param array {
611                         *    @type string $tab     (required)
612                         *    @type string $content (optional)
613                         * }
614                         */
615                        $tabs = apply_filters( 'wpmem_user_profile_tabs', array() ); 
616
617                        if ( ! empty( $tabs ) ) { 
618?>
619<script>
620        jQuery(document).ready(function($){
621                $("#wpmem_user_profile_tabs").tabs();
622        });
623</script>
624<?php
625                                echo '<div id="wpmem_user_profile_tabs">';
626                                echo '<ul>';
627                                foreach ( $tabs as $key => $value ) {
628                                        echo '<li><a href="#wpmem_user_profile_tabs-' . esc_attr( $key ) . '">' . esc_attr( $value['tab'] ) . '</a></li>';
629                                }
630                                echo '</ul>';
631                                foreach ( $tabs as $key => $value ) {
632                                        echo '<div id="wpmem_user_profile_tabs-' . esc_attr( $key ) . '">';
633                                        echo ( isset( $value['content'] ) ) ? esc_attr( $value['content'] ) : '';
634                                        do_action( 'wpmem_user_profile_tabs_content', $key );
635                                        echo '</div>';
636                                }
637                                echo '</div>';
638                        }
639                }
640        }
641}
Note: See TracBrowser for help on using the repository browser.