Version Description
- Bug fix in user export that caused usernames to be dropped.
- Bug fix to allow admins to edit their own profile.
- Bug fix for jquery with regards to select2, only load if products are enabled.
- Added email API.
- Added product attribute to [wpmem_logged_in] shortcode.
- Added wpmem_force_ssl() API function.
- Added wpmem_set_as_logged_in() API function.
- Added filters to remove posts marked hidden from previous/next links.
- Updated user login function to use WP script, facilitates login with username OR email, removes wpmem_login_fields filter, changes to wp_safe_redirect().
- Updated password change for maintaining login state.
- Moved wpmem_fields(), wpmem_form_label(), and wpmem_form_field() to api-forms.php.
- Moved wpmem_user_has_role(), wpmem_user_has_meta(), wpmem_is_user_activated(), wpmem_user_data(), wpmem_update_user_role(), and wpmem_user_has_access() to api-users.php.
- Moved wpmem_do_excerpt(), wpmem_texturize(), wpmem_get_excluded_meta(), wpmem_use_ssl(), wpmem_write_log(), wpmem_load_dropins(), wpmem_array_insert(), and wpmem_get_sub_str() to api-utilities.php.
- Moved wpmem_wp_reserved_terms() to admin API.
- Deprecated wpmem_check_activated() and wpmem_use_ssl().
- Removed obsolete functions wpmem_enqueue_style(), wpmem_convert_tag(), wpmem_no_reset(), and wpmem_user_profile_multipart().
- Applied wpmem_force_ssl() to stylesheet in case it needs to load securely (even if the setting is saved as http://).
Download this release
Release Info
Developer | cbutlerjr |
Plugin | WP-Members Membership Plugin |
Version | 3.2.3 |
Comparing to | |
See all releases |
Code changes from version 3.2.2 to 3.2.3
- admin/admin.php +1 -1
- admin/includes/api.php +14 -0
- admin/includes/class-wp-members-admin-api.php +32 -8
- admin/includes/class-wp-members-products-admin.php +19 -0
- admin/js/admin.js +0 -6
- admin/post.php +2 -2
- admin/tab-fields.php +16 -12
- admin/user-export.php +2 -2
- admin/users.php +9 -5
- inc/api-email.php +94 -0
- inc/api-forms.php +120 -0
- inc/api-users.php +192 -0
- inc/api-utilities.php +194 -0
- inc/api.php +0 -289
- inc/class-wp-members-forms.php +3 -2
- inc/class-wp-members-products.php +26 -42
- inc/class-wp-members-shortcodes.php +10 -3
- inc/class-wp-members-user-profile.php +2 -1
- inc/class-wp-members-user.php +71 -29
- inc/class-wp-members.php +270 -31
- inc/core.php +0 -35
- inc/deprecated.php +20 -77
- inc/dialogs.php +4 -1
- inc/utilities.php +0 -351
- inc/wp-registration.php +2 -2
- readme.txt +30 -5
- wp-members.php +2 -2
admin/admin.php
CHANGED
@@ -51,7 +51,7 @@ function wpmem_admin() {
|
|
51 |
|
52 |
<div class="wrap">
|
53 |
<?php
|
54 |
-
$tab = (
|
55 |
|
56 |
// Render the tab being displayed.
|
57 |
$wpmem->admin->do_tabs( $tab );
|
51 |
|
52 |
<div class="wrap">
|
53 |
<?php
|
54 |
+
$tab = sanitize_text_field( wpmem_get( 'tab', 'options', 'get' ) );
|
55 |
|
56 |
// Render the tab being displayed.
|
57 |
$wpmem->admin->do_tabs( $tab );
|
admin/includes/api.php
CHANGED
@@ -102,4 +102,18 @@ function wpmem_admin_user_profile( $user_id ) {
|
|
102 |
function wpmem_admin_form_post_url( $args = false ) {
|
103 |
global $wpmem;
|
104 |
return $wpmem->admin->form_post_url( $args );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
}
|
102 |
function wpmem_admin_form_post_url( $args = false ) {
|
103 |
global $wpmem;
|
104 |
return $wpmem->admin->form_post_url( $args );
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Returns an array of WordPress reserved terms.
|
109 |
+
*
|
110 |
+
* @since 3.0.2
|
111 |
+
* @since 3.2.3 Moved to Admin API as wrapper for WP_Members_Admin_API::wp_reserved_terms().
|
112 |
+
*
|
113 |
+
* @global object $wpmem
|
114 |
+
* @return array An array of WordPress reserved terms.
|
115 |
+
*/
|
116 |
+
function wpmem_wp_reserved_terms() {
|
117 |
+
global $wpmem;
|
118 |
+
return $wpmem->admin->wp_reserved_terms();
|
119 |
}
|
admin/includes/class-wp-members-admin-api.php
CHANGED
@@ -461,8 +461,7 @@ class WP_Members_Admin_API {
|
|
461 |
$this->current_form = $current_form;
|
462 |
$this->current_form_fields = $fields;
|
463 |
*/
|
464 |
-
$current_form = wpmem_get( 'form', $form, 'get' ); //( isset( $_GET['form'] ) ) ? $_GET['form'] : $form;
|
465 |
-
$this->current_form = $current_form;
|
466 |
global $wpmem;
|
467 |
// Add numeric array form fields as associative
|
468 |
//foreach( $wpmem->fields as $field ) {
|
@@ -508,18 +507,20 @@ class WP_Members_Admin_API {
|
|
508 |
* @since 3.2.0 Moved into admin object, renamed dashboard_enqueue_scripts().
|
509 |
* @since 3.2.1 Load js for post.php hook.
|
510 |
*
|
511 |
-
* @
|
|
|
512 |
*/
|
513 |
function dashboard_enqueue_scripts( $hook ) {
|
514 |
-
|
|
|
515 |
wp_enqueue_style( 'wpmem-admin', WPMEM_DIR . 'admin/css/admin.css', '', WPMEM_VERSION );
|
516 |
}
|
517 |
-
if ( 'settings_page_wpmem-settings' == $hook || 'post.php' == $hook ) {
|
518 |
wp_enqueue_script( 'wpmem-admin', WPMEM_DIR . 'admin/js/admin.js', '', WPMEM_VERSION );
|
519 |
}
|
520 |
-
if ( 'post.php' == $hook ) {
|
521 |
-
wp_register_style( 'select2css', '
|
522 |
-
wp_register_script( 'select2', '
|
523 |
wp_enqueue_style( 'select2css' );
|
524 |
wp_enqueue_script( 'select2' );
|
525 |
}
|
@@ -546,6 +547,29 @@ class WP_Members_Admin_API {
|
|
546 |
}
|
547 |
return $links;
|
548 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
549 |
} // End of WP_Members_Admin_API class.
|
550 |
|
551 |
// End of file.
|
461 |
$this->current_form = $current_form;
|
462 |
$this->current_form_fields = $fields;
|
463 |
*/
|
464 |
+
$this->current_form = sanitize_text_field( wpmem_get( 'form', $form, 'get' ) ); //( isset( $_GET['form'] ) ) ? $_GET['form'] : $form;
|
|
|
465 |
global $wpmem;
|
466 |
// Add numeric array form fields as associative
|
467 |
//foreach( $wpmem->fields as $field ) {
|
507 |
* @since 3.2.0 Moved into admin object, renamed dashboard_enqueue_scripts().
|
508 |
* @since 3.2.1 Load js for post.php hook.
|
509 |
*
|
510 |
+
* @global object $wpmem
|
511 |
+
* @param string $hook The admin screen hook being loaded.
|
512 |
*/
|
513 |
function dashboard_enqueue_scripts( $hook ) {
|
514 |
+
global $wpmem;
|
515 |
+
if ( 'edit.php' == $hook || 'settings_page_wpmem-settings' == $hook || 'post.php' == $hook || 'post-new.php' == $hook || 'user-edit.php' == $hook || 'profile.php' == $hook ) {
|
516 |
wp_enqueue_style( 'wpmem-admin', WPMEM_DIR . 'admin/css/admin.css', '', WPMEM_VERSION );
|
517 |
}
|
518 |
+
if ( 'settings_page_wpmem-settings' == $hook || 'post.php' == $hook || 'post-new.php' == $hook ) {
|
519 |
wp_enqueue_script( 'wpmem-admin', WPMEM_DIR . 'admin/js/admin.js', '', WPMEM_VERSION );
|
520 |
}
|
521 |
+
if ( ( 'post.php' == $hook || 'post-new.php' == $hook ) && 1 == $wpmem->enable_products ) {
|
522 |
+
wp_register_style( 'select2css', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/css/select2.min.css', false, '4.0.5', 'all' );
|
523 |
+
wp_register_script( 'select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js', array( 'jquery' ), '4.0.5', true );
|
524 |
wp_enqueue_style( 'select2css' );
|
525 |
wp_enqueue_script( 'select2' );
|
526 |
}
|
547 |
}
|
548 |
return $links;
|
549 |
}
|
550 |
+
|
551 |
+
/**
|
552 |
+
* Returns an array of WordPress reserved terms.
|
553 |
+
*
|
554 |
+
* @since 3.0.2
|
555 |
+
* @since 3.2.3 Moved to WP_Members_Admin_API class.
|
556 |
+
*
|
557 |
+
* @return array An array of WordPress reserved terms.
|
558 |
+
*/
|
559 |
+
function wp_reserved_terms() {
|
560 |
+
$reserved_terms = array( 'attachment', 'attachment_id', 'author', 'author_name', 'calendar', 'cat', 'category', 'category__and', 'category__in', 'category__not_in', 'category_name', 'comments_per_page', 'comments_popup', 'customize_messenger_channel', 'customized', 'cpage', 'day', 'debug', 'error', 'exact', 'feed', 'fields', 'hour', 'link_category', 'm', 'minute', 'monthnum', 'more', 'name', 'nav_menu', 'nonce', 'nopaging', 'offset', 'order', 'orderby', 'p', 'page', 'page_id', 'paged', 'pagename', 'pb', 'perm', 'post', 'post__in', 'post__not_in', 'post_format', 'post_mime_type', 'post_status', 'post_tag', 'post_type', 'posts', 'posts_per_archive_page', 'posts_per_page', 'preview', 'robots', 'role', 's', 'search', 'second', 'sentence', 'showposts', 'static', 'subpost', 'subpost_id', 'tag', 'tag__and', 'tag__in', 'tag__not_in', 'tag_id', 'tag_slug__and', 'tag_slug__in', 'taxonomy', 'tb', 'term', 'theme', 'type', 'w', 'withcomments', 'withoutcomments', 'year' );
|
561 |
+
|
562 |
+
/**
|
563 |
+
* Filter the array of reserved terms.
|
564 |
+
*
|
565 |
+
* @since 3.0.2
|
566 |
+
*
|
567 |
+
* @param array $reserved_terms
|
568 |
+
*/
|
569 |
+
$reserved_terms = apply_filters( 'wpmem_wp_reserved_terms', $reserved_terms );
|
570 |
+
|
571 |
+
return $reserved_terms;
|
572 |
+
}
|
573 |
} // End of WP_Members_Admin_API class.
|
574 |
|
575 |
// End of file.
|
admin/includes/class-wp-members-products-admin.php
CHANGED
@@ -30,6 +30,7 @@ class WP_Members_Products_Admin {
|
|
30 |
add_action( 'save_post', array( $this, 'save_details' ) );
|
31 |
add_action( 'wpmem_admin_after_block_meta', array( $this, 'add_product_to_post' ), 10, 2 );
|
32 |
add_action( 'wpmem_admin_block_meta_save', array( $this, 'save_product_to_post' ), 10, 3 );
|
|
|
33 |
}
|
34 |
}
|
35 |
|
@@ -276,4 +277,22 @@ class WP_Members_Products_Admin {
|
|
276 |
}
|
277 |
}
|
278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
}
|
30 |
add_action( 'save_post', array( $this, 'save_details' ) );
|
31 |
add_action( 'wpmem_admin_after_block_meta', array( $this, 'add_product_to_post' ), 10, 2 );
|
32 |
add_action( 'wpmem_admin_block_meta_save', array( $this, 'save_product_to_post' ), 10, 3 );
|
33 |
+
add_action( 'admin_footer', array( $this, 'enqueue_select2' ) );
|
34 |
}
|
35 |
}
|
36 |
|
277 |
}
|
278 |
}
|
279 |
|
280 |
+
/**
|
281 |
+
* Enqueue select2 JS.
|
282 |
+
*
|
283 |
+
* @since 3.2.3
|
284 |
+
*/
|
285 |
+
function enqueue_select2() {
|
286 |
+
$screen = get_current_screen();
|
287 |
+
if ( $screen->base == 'post' && $screen->parent_base == 'edit' ) { ?>
|
288 |
+
<script language="javascript">
|
289 |
+
(function($) {
|
290 |
+
$(document).ready(function() {
|
291 |
+
$('.wpmem-product-select2').select2();
|
292 |
+
});
|
293 |
+
})(jQuery);
|
294 |
+
</script><?php
|
295 |
+
}
|
296 |
+
}
|
297 |
+
|
298 |
}
|
admin/js/admin.js
CHANGED
@@ -223,10 +223,4 @@
|
|
223 |
}
|
224 |
});
|
225 |
});
|
226 |
-
})(jQuery);
|
227 |
-
|
228 |
-
(function($) {
|
229 |
-
$(document).ready(function() {
|
230 |
-
$('.wpmem-product-select2').select2();
|
231 |
-
});
|
232 |
})(jQuery);
|
223 |
}
|
224 |
});
|
225 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
})(jQuery);
|
admin/post.php
CHANGED
@@ -77,7 +77,7 @@ function wpmem_posts_page_load() {
|
|
77 |
// Validate nonce.
|
78 |
check_admin_referer( 'bulk-posts' );
|
79 |
// Get the posts.
|
80 |
-
$posts = (
|
81 |
// Convert action.
|
82 |
$status = ( 'hide' == $action ) ? 2 : ( ( 'block' == $action ) ? 1 : 0 );
|
83 |
// Update posts.
|
@@ -324,7 +324,7 @@ function wpmem_post_columns( $columns ) {
|
|
324 |
function wpmem_post_columns_content( $column_name, $post_ID ) {
|
325 |
|
326 |
global $wpmem;
|
327 |
-
$post_type = (
|
328 |
|
329 |
if ( $column_name == 'wpmem_block' ) {
|
330 |
|
77 |
// Validate nonce.
|
78 |
check_admin_referer( 'bulk-posts' );
|
79 |
// Get the posts.
|
80 |
+
$posts = wpmem_get( 'post', '', 'request' );
|
81 |
// Convert action.
|
82 |
$status = ( 'hide' == $action ) ? 2 : ( ( 'block' == $action ) ? 1 : 0 );
|
83 |
// Update posts.
|
324 |
function wpmem_post_columns_content( $column_name, $post_ID ) {
|
325 |
|
326 |
global $wpmem;
|
327 |
+
$post_type = sanitize_text_field( wpmem_get( 'post_type', 'post', 'request' ) );
|
328 |
|
329 |
if ( $column_name == 'wpmem_block' ) {
|
330 |
|
admin/tab-fields.php
CHANGED
@@ -107,19 +107,23 @@ function wpmem_a_render_fields_tab() {
|
|
107 |
if ( 'delete' == $delete_action ) {
|
108 |
$delete_fields = wpmem_get( 'delete' ); ?>
|
109 |
|
110 |
-
<p><?php _e( 'Are you sure you want to delete the following fields?', 'wp-members' ); ?></p>
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
} ?>
|
116 |
-
|
117 |
-
<?php
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
123 |
} else {
|
124 |
|
125 |
if ( 'delete_confirmed' == wpmem_get( 'dodelete' ) ) {
|
107 |
if ( 'delete' == $delete_action ) {
|
108 |
$delete_fields = wpmem_get( 'delete' ); ?>
|
109 |
|
|
|
110 |
|
111 |
+
|
112 |
+
<?php if ( empty( $delete_fields ) ) { ?>
|
113 |
+
<p><?php _e( 'No fields selected for deletion', 'wp-members' ); ?></p>
|
114 |
+
<?php } else { ?>
|
115 |
+
<p><?php _e( 'Are you sure you want to delete the following fields?', 'wp-members' ); ?></p>
|
116 |
+
<?php foreach ( $delete_fields as $meta ) {
|
117 |
+
$meta = esc_html( $meta );
|
118 |
+
echo esc_html( $wpmem->fields[ $meta ]['label'] ) . ' (meta key: ' . $meta . ')<br />';
|
119 |
+
} ?>
|
120 |
+
<form name="<?php echo esc_attr( $delete_action ); ?>" id="<?php echo esc_attr( $delete_action ); ?>" method="post" action="<?php echo esc_url( wpmem_admin_form_post_url() ); ?>">
|
121 |
+
<?php // wp_nonce_field( 'wpmem-delete-fields' ); ?>
|
122 |
+
<input type="hidden" name="delete_fields" value="<?php echo esc_attr( implode( ",", $delete_fields ) ); ?>" />
|
123 |
+
<input type="hidden" name="dodelete" value="delete_confirmed" />
|
124 |
+
<?php submit_button( 'Delete Fields' ); ?>
|
125 |
+
</form><?php
|
126 |
+
}
|
127 |
} else {
|
128 |
|
129 |
if ( 'delete_confirmed' == wpmem_get( 'dodelete' ) ) {
|
admin/user-export.php
CHANGED
@@ -107,11 +107,11 @@ function wpmem_export_users( $args, $users = null ) {
|
|
107 |
|
108 |
$user_info = get_userdata( $user );
|
109 |
|
110 |
-
$wp_user_fields = [ 'user_email', 'user_nicename', 'user_url', 'display_name' ];
|
111 |
$row = array( 'ID' => $user_info->ID, 'username' => $user_info->user_login );
|
112 |
foreach ( $args['export_fields'] as $meta => $field ) {
|
113 |
if ( in_array( $meta, $wp_user_fields ) ) {
|
114 |
-
$row[ $meta ] = $user_info->{$meta};
|
115 |
} else {
|
116 |
$raw_data = get_user_meta( $user, $meta, true );
|
117 |
$row[ $meta ] = ( $args['entity_decode'] ) ? html_entity_decode( $raw_data ) : $raw_data;
|
107 |
|
108 |
$user_info = get_userdata( $user );
|
109 |
|
110 |
+
$wp_user_fields = [ 'username', 'user_email', 'user_nicename', 'user_url', 'display_name' ];
|
111 |
$row = array( 'ID' => $user_info->ID, 'username' => $user_info->user_login );
|
112 |
foreach ( $args['export_fields'] as $meta => $field ) {
|
113 |
if ( in_array( $meta, $wp_user_fields ) ) {
|
114 |
+
$row[ $meta ] = ( 'username' == $meta ) ? $user_info->user_login : $user_info->{$meta};
|
115 |
} else {
|
116 |
$raw_data = get_user_meta( $user, $meta, true );
|
117 |
$row[ $meta ] = ( $args['entity_decode'] ) ? html_entity_decode( $raw_data ) : $raw_data;
|
admin/users.php
CHANGED
@@ -71,7 +71,7 @@ function wpmem_bulk_user_action() {
|
|
71 |
*/
|
72 |
function wpmem_insert_activate_link( $actions, $user_object ) {
|
73 |
global $wpmem;
|
74 |
-
if (
|
75 |
|
76 |
$var = get_user_meta( $user_object->ID, 'active', true );
|
77 |
|
@@ -193,9 +193,13 @@ function wpmem_users_page_load() {
|
|
193 |
|
194 |
case 'export':
|
195 |
|
196 |
-
$users = (
|
|
|
|
|
|
|
|
|
197 |
include_once( WPMEM_PATH . 'admin/user-export.php' );
|
198 |
-
wpmem_export_users( array( 'export'=>'selected' ), $
|
199 |
return;
|
200 |
break;
|
201 |
|
@@ -313,7 +317,7 @@ function wpmem_users_views( $views ) {
|
|
313 |
$arr['deactivated'] = __( 'Deactivated', 'wp-members' );
|
314 |
}
|
315 |
$arr['notexported'] = __( 'Not Exported', 'wp-members' );
|
316 |
-
$show = (
|
317 |
|
318 |
foreach ( $arr as $key => $val ) {
|
319 |
$link = "users.php?action=show&show=" . $key;
|
@@ -513,7 +517,7 @@ function wpmem_a_deactivate_user( $user_id ) {
|
|
513 |
function wpmem_a_pre_user_query( $user_search ) {
|
514 |
|
515 |
global $wpdb;
|
516 |
-
$show = sanitize_text_field(
|
517 |
switch ( $show ) {
|
518 |
|
519 |
case 'notactive':
|
71 |
*/
|
72 |
function wpmem_insert_activate_link( $actions, $user_object ) {
|
73 |
global $wpmem;
|
74 |
+
if ( 1 == $wpmem->mod_reg ) {
|
75 |
|
76 |
$var = get_user_meta( $user_object->ID, 'active', true );
|
77 |
|
193 |
|
194 |
case 'export':
|
195 |
|
196 |
+
$users = wpmem_get( 'users', false, 'request' );
|
197 |
+
$sanitized_users = array();
|
198 |
+
foreach ( $users as $user ) {
|
199 |
+
$sanitized_users[] = filter_var( $user, FILTER_VALIDATE_INT );
|
200 |
+
}
|
201 |
include_once( WPMEM_PATH . 'admin/user-export.php' );
|
202 |
+
wpmem_export_users( array( 'export'=>'selected' ), $sanitized_users );
|
203 |
return;
|
204 |
break;
|
205 |
|
317 |
$arr['deactivated'] = __( 'Deactivated', 'wp-members' );
|
318 |
}
|
319 |
$arr['notexported'] = __( 'Not Exported', 'wp-members' );
|
320 |
+
$show = sanitize_text_field( wpmem_get( 'show', false, 'get' ) );
|
321 |
|
322 |
foreach ( $arr as $key => $val ) {
|
323 |
$link = "users.php?action=show&show=" . $key;
|
517 |
function wpmem_a_pre_user_query( $user_search ) {
|
518 |
|
519 |
global $wpdb;
|
520 |
+
$show = sanitize_text_field( wpmem_get( 'show', '', 'get' ) );
|
521 |
switch ( $show ) {
|
522 |
|
523 |
case 'notactive':
|
inc/api-email.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP-Members Email API Functions
|
4 |
+
*
|
5 |
+
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
+
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
+
* Copyright (c) 2006-2018 Chad Butler
|
8 |
+
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
+
*
|
10 |
+
* @package WP-Members
|
11 |
+
* @subpackage WP-Members API Functions
|
12 |
+
* @author Chad Butler
|
13 |
+
* @copyright 2006-2018
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Returns the wp_mail from address (if set).
|
18 |
+
*
|
19 |
+
* @since 3.2.3
|
20 |
+
*
|
21 |
+
* @global object $wpmem
|
22 |
+
* @return string $wpmem_mail_from|$email
|
23 |
+
*/
|
24 |
+
function wpmem_email_from() {
|
25 |
+
global $wpmem;
|
26 |
+
return $wpmem->email->from;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Returns the wp_mail from name (if set).
|
31 |
+
*
|
32 |
+
* @since 3.2.3
|
33 |
+
*
|
34 |
+
* @global object $wpmem
|
35 |
+
* @return string $wpmem_mail_from_name|$name
|
36 |
+
*/
|
37 |
+
function wpmem_email_from_name() {
|
38 |
+
global $wpmem;
|
39 |
+
return $wpmem->email->from_name;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Builds emails for the user.
|
44 |
+
*
|
45 |
+
* @since 3.2.3
|
46 |
+
*
|
47 |
+
* @global object $wpmem The WP_Members object.
|
48 |
+
* @param mixed $args Settings arguments or The User's ID.
|
49 |
+
* @param string $password Password from the registration process.
|
50 |
+
* @param string $toggle Toggle indicating the email being sent (newreg|newmod|appmod|repass|getuser).
|
51 |
+
* @param array $wpmem_fields Array of the WP-Members fields (defaults to null).
|
52 |
+
* @param array $fields Array of the registration data (defaults to null).
|
53 |
+
* @param array $custom Array of custom email information (defaults to null).
|
54 |
+
*/
|
55 |
+
function wpmem_email_to_user( $args, $password = null, $tag = null, $wpmem_fields = null, $field_data = null, $custom = null ) {
|
56 |
+
global $wpmem;
|
57 |
+
if ( is_array( $args ) ) {
|
58 |
+
$user_id = $args['user_id'];
|
59 |
+
$password = $args['password'];
|
60 |
+
$tag = $args['tag'];
|
61 |
+
$wpmem_fields = $args['wpmem_fields'];
|
62 |
+
$field_data = $args['field_data'];
|
63 |
+
$custom = $args['custom'];
|
64 |
+
} else {
|
65 |
+
$user_id = $args;
|
66 |
+
}
|
67 |
+
$wpmem->email->to_user( $user_id, $password, $toggle, $wpmem_fields, $field_data, $custom );
|
68 |
+
return;
|
69 |
+
}
|
70 |
+
|
71 |
+
if ( ! function_exists( 'wpmem_notify_admin' ) ):
|
72 |
+
/**
|
73 |
+
* Builds the email for admin notification of new user registration.
|
74 |
+
*
|
75 |
+
* @since 2.3
|
76 |
+
* @since 3.2.3 Changed inputs.
|
77 |
+
*
|
78 |
+
* @global object $wpmem The WP_Members object.
|
79 |
+
* @param mixed $args Settings arguments or The User's ID.
|
80 |
+
* @param array $wpmem_fields Array of the WP-Members fields (defaults to null).
|
81 |
+
* @param array $field_data Array of the registration data (defaults to null).
|
82 |
+
*/
|
83 |
+
function wpmem_notify_admin( $args, $wpmem_fields = null, $field_data = null ) {
|
84 |
+
global $wpmem;
|
85 |
+
if ( is_array( $args ) ) {
|
86 |
+
$user_id = $args['user_id'];
|
87 |
+
$wpmem_fields = $args['wpmem_fields'];
|
88 |
+
$field_data = $args['field_data'];
|
89 |
+
} else {
|
90 |
+
$user_id = $args;
|
91 |
+
}
|
92 |
+
$wpmem->email->notify_admin( $user_id, $wpmem_fields, $field_data );
|
93 |
+
}
|
94 |
+
endif;
|
inc/api-forms.php
CHANGED
@@ -1,4 +1,24 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
/**
|
4 |
* Invokes a login form.
|
@@ -45,3 +65,103 @@ function wpmem_register_form( $args ) {
|
|
45 |
global $wpmem;
|
46 |
return $wpmem->forms->register_form( $args );
|
47 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* WP-Members API Functions
|
4 |
+
*
|
5 |
+
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
+
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
+
* Copyright (c) 2006-2018 Chad Butler
|
8 |
+
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
+
*
|
10 |
+
* @package WP-Members
|
11 |
+
* @subpackage WP-Members API Functions
|
12 |
+
* @author Chad Butler
|
13 |
+
* @copyright 2006-2018
|
14 |
+
*
|
15 |
+
* Functions included:
|
16 |
+
*
|
17 |
+
* - wpmem_register_form
|
18 |
+
* - wpmem_form_field
|
19 |
+
* - wpmem_form_label
|
20 |
+
* - wpmem_fields
|
21 |
+
*/
|
22 |
|
23 |
/**
|
24 |
* Invokes a login form.
|
65 |
global $wpmem;
|
66 |
return $wpmem->forms->register_form( $args );
|
67 |
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Wrapper for $wpmem->create_form_field().
|
71 |
+
*
|
72 |
+
* @since 3.1.2
|
73 |
+
* @since 3.2.0 Accepts wpmem_create_formfield() arguments.
|
74 |
+
*
|
75 |
+
* @global object $wpmem The WP_Members object class.
|
76 |
+
* @param string|array $args {
|
77 |
+
* @type string $name (required) The field meta key.
|
78 |
+
* @type string $type (required) The field HTML type (url, email, image, file, checkbox, text, textarea, password, hidden, select, multiselect, multicheckbox, radio).
|
79 |
+
* @type string $value (required) The field's value (can be a null value).
|
80 |
+
* @type string $compare (required) Compare value.
|
81 |
+
* @type string $class (optional) Class identifier for the field.
|
82 |
+
* @type boolean $required (optional) If a value is required default: true).
|
83 |
+
* @type string $delimiter (optional) The field delimiter (pipe or comma, default: | ).
|
84 |
+
* @type string $placeholder (optional) Defines the placeholder attribute.
|
85 |
+
* @type string $pattern (optional) Adds a regex pattern to the field (HTML5).
|
86 |
+
* @type string $title (optional) Defines the title attribute.
|
87 |
+
* @type string $min (optional) Adds a min attribute (HTML5).
|
88 |
+
* @type string $max (optional) Adds a max attribute (HTML5).
|
89 |
+
* @type string $rows (optional) Adds rows attribute to textarea.
|
90 |
+
* @type string $cols (optional) Adds cols attribute to textarea.
|
91 |
+
* }
|
92 |
+
* @param string $type The field type.
|
93 |
+
* @param string $value The default value for the field.
|
94 |
+
* @param string $valtochk Optional for comparing the default value of the field.
|
95 |
+
* @param string $class Optional for setting a specific CSS class for the field.
|
96 |
+
* @return string The HTML of the form field.
|
97 |
+
*/
|
98 |
+
//function wpmem_form_field( $args ) {
|
99 |
+
function wpmem_form_field( $name, $type=null, $value=null, $valtochk=null, $class='textbox' ) {
|
100 |
+
global $wpmem;
|
101 |
+
if ( is_array( $name ) ) {
|
102 |
+
$args = $name;
|
103 |
+
} else {
|
104 |
+
$args = array(
|
105 |
+
'name' => $name,
|
106 |
+
'type' => $type,
|
107 |
+
'value' => $value,
|
108 |
+
'compare' => $valtochk,
|
109 |
+
'class' => $class,
|
110 |
+
);
|
111 |
+
}
|
112 |
+
return $wpmem->forms->create_form_field( $args );
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Wrapper for $wpmem->create_form_label().
|
117 |
+
*
|
118 |
+
* @since 3.1.7
|
119 |
+
*
|
120 |
+
* @global object $wpmem
|
121 |
+
* @param array $args {
|
122 |
+
* @type string $meta_key
|
123 |
+
* @type string $label
|
124 |
+
* @type string $type
|
125 |
+
* @type string $class (optional)
|
126 |
+
* @type string $required (optional)
|
127 |
+
* @type string $req_mark (optional)
|
128 |
+
* }
|
129 |
+
* @return string The HTML of the form label.
|
130 |
+
*/
|
131 |
+
function wpmem_form_label( $args ) {
|
132 |
+
global $wpmem;
|
133 |
+
return $wpmem->forms->create_form_label( $args );
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Wrapper to get form fields.
|
138 |
+
*
|
139 |
+
* @since 3.1.1
|
140 |
+
* @since 3.1.5 Checks if fields array is set or empty before returning.
|
141 |
+
* @since 3.1.7 Added wpmem_form_fields filter.
|
142 |
+
*
|
143 |
+
* @global object $wpmem The WP_Members object.
|
144 |
+
* @param string $tag The action being used (default: null).
|
145 |
+
* @param string $form The form being generated.
|
146 |
+
* @return array $fields The form fields.
|
147 |
+
*/
|
148 |
+
function wpmem_fields( $tag = '', $form = 'default' ) {
|
149 |
+
global $wpmem;
|
150 |
+
// Load fields if none are loaded.
|
151 |
+
if ( ! isset( $wpmem->fields ) || empty( $wpmem->fields ) ) {
|
152 |
+
$wpmem->load_fields( $form );
|
153 |
+
}
|
154 |
+
|
155 |
+
// @todo Convert tag.
|
156 |
+
$tag = $wpmem->convert_tag( $tag );
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Filters the fields array.
|
160 |
+
*
|
161 |
+
* @since 3.1.7
|
162 |
+
*
|
163 |
+
* @param array $wpmem->fields
|
164 |
+
* @param string $tag (optional)
|
165 |
+
*/
|
166 |
+
return apply_filters( 'wpmem_fields', $wpmem->fields, $tag );
|
167 |
+
}
|
inc/api-users.php
ADDED
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP-Members User API Functions
|
4 |
+
*
|
5 |
+
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
+
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
+
* Copyright (c) 2006-2018 Chad Butler
|
8 |
+
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
+
*
|
10 |
+
* @package WP-Members
|
11 |
+
* @subpackage WP-Members API Functions
|
12 |
+
* @author Chad Butler
|
13 |
+
* @copyright 2006-2018
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Checks if user has a particular role.
|
18 |
+
*
|
19 |
+
* Utility function to check if a given user has a specific role. Users can
|
20 |
+
* have multiple roles assigned, so it checks the role array rather than using
|
21 |
+
* the incorrect method of current_user_can( 'role_name' ). The function can
|
22 |
+
* check the role of the current user (default) or a specific user (if $user_id
|
23 |
+
* is passed).
|
24 |
+
*
|
25 |
+
* @since 3.1.1
|
26 |
+
* @since 3.1.6 Include accepting an array of roles to check.
|
27 |
+
* @since 3.1.9 Return false if user is not logged in.
|
28 |
+
* @since 3.2.0 Change return false to not logged in AND no user id.
|
29 |
+
*
|
30 |
+
* @global object $current_user Current user object.
|
31 |
+
* @global object $wpmem WP_Members object.
|
32 |
+
* @param string|array $role Slug or array of slugs of the role being checked.
|
33 |
+
* @param int $user_id ID of the user being checked (optional).
|
34 |
+
* @return boolean $has_role True if user has the role, otherwise false.
|
35 |
+
*/
|
36 |
+
function wpmem_user_has_role( $role, $user_id = false ) {
|
37 |
+
if ( ! is_user_logged_in() && ! $user_id ) {
|
38 |
+
return false;
|
39 |
+
}
|
40 |
+
global $current_user, $wpmem;
|
41 |
+
$has_role = false;
|
42 |
+
if ( $user_id ) {
|
43 |
+
$user = get_userdata( $user_id );
|
44 |
+
}
|
45 |
+
if ( is_user_logged_in() && ! $user_id ) {
|
46 |
+
$user = ( isset( $current_user ) ) ? $current_user : wp_get_current_user();
|
47 |
+
}
|
48 |
+
if ( is_array( $role ) ) {
|
49 |
+
foreach ( $role as $r ) {
|
50 |
+
if ( in_array( $r, $user->roles ) ) {
|
51 |
+
return true;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
} else {
|
55 |
+
return ( in_array( $role, $user->roles ) ) ? true : $has_role;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Checks if a user has a given meta value.
|
61 |
+
*
|
62 |
+
* @since 3.1.8
|
63 |
+
*
|
64 |
+
* @global object $wpmem WP_Members object.
|
65 |
+
* @param string $meta Meta key being checked.
|
66 |
+
* @param string $value Value the meta key should have (optional).
|
67 |
+
* @param int $user_id ID of the user being checked (optional).
|
68 |
+
* @return boolean $has_meta True if user has the meta value, otherwise false.
|
69 |
+
*/
|
70 |
+
function wpmem_user_has_meta( $meta, $value = false, $user_id = false ) {
|
71 |
+
global $wpmem;
|
72 |
+
$user_id = ( $user_id ) ? $user_id : get_current_user_id();
|
73 |
+
$has_meta = false;
|
74 |
+
$user_value = get_user_meta( $user_id, $meta, true );
|
75 |
+
if ( $value ) {
|
76 |
+
$has_meta = ( $user_value == $value ) ? true : $has_meta;
|
77 |
+
} else {
|
78 |
+
$has_meta = ( $value ) ? true : $has_meta;
|
79 |
+
}
|
80 |
+
return $has_meta;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Checks if a user is activated.
|
85 |
+
*
|
86 |
+
* @since 3.1.7
|
87 |
+
* @since 3.2.3 Now a wrapper for WP_Members_Users::is_user_activated().
|
88 |
+
*
|
89 |
+
* @global object $wpmem
|
90 |
+
* @param int $user_id
|
91 |
+
* @return bool
|
92 |
+
*/
|
93 |
+
function wpmem_is_user_activated( $user_id = false ) {
|
94 |
+
global $wpmem;
|
95 |
+
return $wpmem->user->is_user_activated( $user_id );
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Gets an array of the user's registration data.
|
100 |
+
*
|
101 |
+
* Returns an array keyed by meta keys of the user's registration data for
|
102 |
+
* all fields in the WP-Members Fields. Returns the current user unless
|
103 |
+
* a user ID is specified.
|
104 |
+
*
|
105 |
+
* @since 3.2.0
|
106 |
+
*
|
107 |
+
* @global object $wpmem
|
108 |
+
* @param integer $user_id
|
109 |
+
* @return array $user_fields
|
110 |
+
*/
|
111 |
+
function wpmem_user_data( $user_id = false ) {
|
112 |
+
global $wpmem;
|
113 |
+
return $wpmem->user_fields( $user_id );
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Updates a user's role.
|
118 |
+
*
|
119 |
+
* This is a wrapper for $wpmem->update_user_role(). It can add a role to a
|
120 |
+
* user, change or remove the user's role. If no action is specified it will
|
121 |
+
* change the role.
|
122 |
+
*
|
123 |
+
* @since 3.2.0
|
124 |
+
*
|
125 |
+
* @global object $wpmem
|
126 |
+
* @param integer $user_id (required)
|
127 |
+
* @param string $role (required)
|
128 |
+
* @param string $action (optional add|remove|set default:set)
|
129 |
+
*/
|
130 |
+
function wpmem_update_user_role( $user_id, $role, $action = 'set' ) {
|
131 |
+
global $wpmem;
|
132 |
+
$wpmem->user->update_user_role( $user_id, $role, $action );
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* A function for checking user access criteria.
|
137 |
+
*
|
138 |
+
* @since 3.2.0
|
139 |
+
* @since 3.2.3 Reversed order of arguments.
|
140 |
+
*
|
141 |
+
* @param mixed $product
|
142 |
+
* @param integer $user_id User ID (optional|default: false).
|
143 |
+
* @return boolean $access If user has access.
|
144 |
+
*/
|
145 |
+
function wpmem_user_has_access( $product, $user_id = false ) {
|
146 |
+
global $wpmem;
|
147 |
+
return $wpmem->user->has_access( $product, $user_id );
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Sets product access for a user.
|
152 |
+
*
|
153 |
+
* @since 3.2.3
|
154 |
+
*
|
155 |
+
* @global object $wpmem
|
156 |
+
* @param string $product
|
157 |
+
* @param int $user_id
|
158 |
+
* @return bool $result
|
159 |
+
*/
|
160 |
+
function wpmem_set_user_product( $product, $user_id = false ) {
|
161 |
+
global $wpmem;
|
162 |
+
return $wpmem->user->set_user_product( $product, $user_id );
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Removes product access for a user.
|
167 |
+
*
|
168 |
+
* @since 3.2.3
|
169 |
+
*
|
170 |
+
* @global object $wpmem
|
171 |
+
* @param string $product
|
172 |
+
* @param int $user_id
|
173 |
+
*/
|
174 |
+
function wpmem_remove_user_product( $product, $user_id = false ) {
|
175 |
+
global $wpmem;
|
176 |
+
$wpmem->user->remove_user_product( $product, $user_id );
|
177 |
+
return;
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Sets a user as logged in.
|
182 |
+
*
|
183 |
+
* @since 3.2.3
|
184 |
+
*
|
185 |
+
* @global object $wpmem
|
186 |
+
* @param int $user_id
|
187 |
+
*/
|
188 |
+
function wpmem_set_as_logged_in( $user_id ) {
|
189 |
+
global $wpmem;
|
190 |
+
$wpmem->user->set_as_logged_in( $user_id );
|
191 |
+
}
|
192 |
+
// End of file.
|
inc/api-utilities.php
ADDED
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP-Members Utility Functions
|
4 |
+
*
|
5 |
+
* Handles primary functions that are carried out in most
|
6 |
+
* situations. Includes commonly used utility functions.
|
7 |
+
*
|
8 |
+
* This file is part of the WP-Members plugin by Chad Butler
|
9 |
+
* You can find out more about this plugin at https://rocketgeek.com
|
10 |
+
* Copyright (c) 2006-2018 Chad Butler
|
11 |
+
* WP-Members(tm) is a trademark of butlerblog.com
|
12 |
+
*
|
13 |
+
* @package WP-Members
|
14 |
+
* @subpackage WP-Members Utility Functions
|
15 |
+
* @author Chad Butler
|
16 |
+
* @copyright 2006-2018
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Sets an array of user meta fields to be excluded from update/insert.
|
21 |
+
*
|
22 |
+
* @since 2.9.3
|
23 |
+
* @since Unknown Now a wrapper for get_excluded_fields().
|
24 |
+
*
|
25 |
+
* @param string $tag A tag so we know where the function is being used.
|
26 |
+
* @return array Array of fields to be excluded from the registration form.
|
27 |
+
*/
|
28 |
+
function wpmem_get_excluded_meta( $tag ) {
|
29 |
+
global $wpmem;
|
30 |
+
return $wpmem->excluded_fields( $tag );
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Returns http:// or https:// depending on ssl.
|
35 |
+
*
|
36 |
+
* @since 2.9.8
|
37 |
+
* @deprecated 3.2.3 Use wpmem_force_ssl() instead.
|
38 |
+
*
|
39 |
+
* @return string https://|http:// depending on whether ssl is being used.
|
40 |
+
*/
|
41 |
+
function wpmem_use_ssl() {
|
42 |
+
return ( is_ssl() ) ? 'https://' : 'http://';
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Forces a URL to be secure (ssl).
|
47 |
+
*
|
48 |
+
* @since 3.2.3
|
49 |
+
*
|
50 |
+
* @param string $url URL to be make secure.
|
51 |
+
* @return string The secure URL.
|
52 |
+
*/
|
53 |
+
function wpmem_force_ssl( $url ) {
|
54 |
+
return ( is_ssl() ) ? preg_replace( "/^http:/i", "https:", $url ) : $url;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Log debugging errors.
|
59 |
+
*
|
60 |
+
* @since 3.1.2
|
61 |
+
*
|
62 |
+
* @param mixed (string|array|object) $log Information to write in the WP debug file.
|
63 |
+
*/
|
64 |
+
function wpmem_write_log ( $log ) {
|
65 |
+
if ( is_array( $log ) || is_object( $log ) ) {
|
66 |
+
error_log( print_r( $log, true ) );
|
67 |
+
} else {
|
68 |
+
error_log( $log );
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* String manipulation utility.
|
74 |
+
*
|
75 |
+
* Manipulates a given string based on the location of another string to return
|
76 |
+
* a requested part or parts of the original string. For extracting a string
|
77 |
+
* to get what is before or after, the returned result is a string. If the
|
78 |
+
* string is requested to be "split" by the needle string, an array containing
|
79 |
+
* the parts before, after, and the "needle" are returned.
|
80 |
+
*
|
81 |
+
* @since 3.2.0
|
82 |
+
*
|
83 |
+
* @param string $needle
|
84 |
+
* @param string $haystack
|
85 |
+
* @param string $position (before|after|split default: 'after')
|
86 |
+
* @param boolean $keep_needle (default:true)
|
87 |
+
* @return string|array $new {
|
88 |
+
* An array of the original string, as split by the "needle" string.
|
89 |
+
*
|
90 |
+
* @type string $before
|
91 |
+
* @type string $after
|
92 |
+
* @type string $needle
|
93 |
+
* }
|
94 |
+
*/
|
95 |
+
function wpmem_get_sub_str( $needle, $haystack, $position = 'after', $keep_needle = true ) {
|
96 |
+
$pos = strpos( $haystack, $needle );
|
97 |
+
if ( false === $pos ) {
|
98 |
+
return $haystack;
|
99 |
+
} else {
|
100 |
+
if ( 'before' == $position ) {
|
101 |
+
$new = ( substr( $haystack, 0, $pos ) );
|
102 |
+
$new = ( $keep_needle ) ? $string . $needle : $new;
|
103 |
+
} elseif ( 'after' == $position ) {
|
104 |
+
$new = ( substr( $haystack, $pos+strlen( $needle ) ) );
|
105 |
+
$new = ( $keep_needle ) ? $needle . $string : $new;
|
106 |
+
} elseif ( 'split' == $position ) {
|
107 |
+
$before = ( substr( $haystack, 0, $pos ) );
|
108 |
+
$after = ( substr( $haystack, $pos+strlen( $needle ) ) );
|
109 |
+
$new = array(
|
110 |
+
'before' => $before,
|
111 |
+
'after' => $after,
|
112 |
+
'needle' => $needle,
|
113 |
+
);
|
114 |
+
}
|
115 |
+
}
|
116 |
+
return $new;
|
117 |
+
}
|
118 |
+
|
119 |
+
if ( ! function_exists( 'wpmem_do_excerpt' ) ):
|
120 |
+
/**
|
121 |
+
* Creates an excerpt on the fly if there is no 'more' tag.
|
122 |
+
*
|
123 |
+
* @since 2.6
|
124 |
+
* @since 3.2.3 Now a wrapper for WP_Members::do_excerpt().
|
125 |
+
*
|
126 |
+
* @global object $post The post object.
|
127 |
+
* @global object $wpmem The WP_Members object.
|
128 |
+
*
|
129 |
+
* @param string $content
|
130 |
+
* @return string $content
|
131 |
+
*/
|
132 |
+
function wpmem_do_excerpt( $content ) {
|
133 |
+
global $post, $more, $wpmem;
|
134 |
+
$content = $wpmem->do_excerpt( $content );
|
135 |
+
return $content;
|
136 |
+
}
|
137 |
+
endif;
|
138 |
+
|
139 |
+
if ( ! function_exists( 'wpmem_texturize' ) ):
|
140 |
+
/**
|
141 |
+
* Overrides the wptexturize filter.
|
142 |
+
*
|
143 |
+
* Currently only used for the login form to remove the <br> tag that WP puts in after the "Remember Me".
|
144 |
+
*
|
145 |
+
* @since 2.6.4
|
146 |
+
* @since 3.2.3 Now a wrapper for WP_Members::texturize().
|
147 |
+
*
|
148 |
+
* @todo Possibly deprecate or severely alter this process as its need may be obsolete.
|
149 |
+
*
|
150 |
+
* @global object $wpmem
|
151 |
+
* @param string $content
|
152 |
+
* @return string $new_content
|
153 |
+
*/
|
154 |
+
function wpmem_texturize( $content ) {
|
155 |
+
global $wpmem;
|
156 |
+
return $wpmem->texturize( $content );
|
157 |
+
}
|
158 |
+
endif;
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Inserts array items at a specific point in an array.
|
162 |
+
*
|
163 |
+
* @since 3.1.6
|
164 |
+
* @since 3.2.3 Moved to utilities api.
|
165 |
+
*
|
166 |
+
* @param array $array Original array.
|
167 |
+
* @param array $new Array of new items to insert into $array.
|
168 |
+
* @param string $key Array key to insert new items before or after.
|
169 |
+
* @param string $loc Location to insert relative to $key (before|after) default:after.
|
170 |
+
* @return array Original array with new items inserted.
|
171 |
+
*/
|
172 |
+
function wpmem_array_insert( array $array, array $new, $key, $loc = 'after' ) {
|
173 |
+
$keys = array_keys( $array );
|
174 |
+
if ( 'before' == $loc ) {
|
175 |
+
$pos = (int) array_search( $key, $keys );
|
176 |
+
} else {
|
177 |
+
$index = array_search( $key, $keys );
|
178 |
+
$pos = ( false === $index ) ? count( $array ) : $index + 1;
|
179 |
+
}
|
180 |
+
return array_merge( array_slice( $array, 0, $pos ), $new, array_slice( $array, $pos ) );
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Wrapper for load_dropins()
|
185 |
+
*
|
186 |
+
* @since 3.1.4
|
187 |
+
* @since 3.2.3 Moved to utilities api.
|
188 |
+
*
|
189 |
+
* @global object $wpmem The WP_Members object.
|
190 |
+
*/
|
191 |
+
function wpmem_load_dropins() {
|
192 |
+
global $wpmem;
|
193 |
+
$wpmem->load_dropins();
|
194 |
+
}
|
inc/api.php
CHANGED
@@ -19,25 +19,18 @@
|
|
19 |
* - wpmem_register_url
|
20 |
* - wpmem_profile_url
|
21 |
* - wpmem_current_url
|
22 |
-
* - wpmem_form_field
|
23 |
-
* - wpmem_form_label
|
24 |
-
* - wpmem_fields
|
25 |
* - wpmem_gettext
|
26 |
* - wpmem_use_custom_dialog
|
27 |
-
* - wpmem_user_has_role
|
28 |
* - wpmem_create_membership_number
|
29 |
* - wpmem_login_status
|
30 |
* - wpmem_get
|
31 |
* - wpmem_is_reg_page
|
32 |
-
* - wpmem_load_dropins
|
33 |
* - wpmem_loginout
|
34 |
-
* - wpmem_array_insert
|
35 |
* - wpmem_is_user_activated
|
36 |
* - wpmem_current_post_id
|
37 |
* - wpmem_user_data
|
38 |
* - wpmem_update_user_role
|
39 |
* - wpmem_display_message
|
40 |
-
* - wpmem_user_has_access
|
41 |
*/
|
42 |
|
43 |
// Exit if accessed directly.
|
@@ -180,106 +173,6 @@ function wpmem_current_post_id() {
|
|
180 |
return url_to_postid( wpmem_current_url() );
|
181 |
}
|
182 |
|
183 |
-
/**
|
184 |
-
* Wrapper for $wpmem->create_form_field().
|
185 |
-
*
|
186 |
-
* @since 3.1.2
|
187 |
-
* @since 3.2.0 Accepts wpmem_create_formfield() arguments.
|
188 |
-
*
|
189 |
-
* @global object $wpmem The WP_Members object class.
|
190 |
-
* @param string|array $args {
|
191 |
-
* @type string $name (required) The field meta key.
|
192 |
-
* @type string $type (required) The field HTML type (url, email, image, file, checkbox, text, textarea, password, hidden, select, multiselect, multicheckbox, radio).
|
193 |
-
* @type string $value (required) The field's value (can be a null value).
|
194 |
-
* @type string $compare (required) Compare value.
|
195 |
-
* @type string $class (optional) Class identifier for the field.
|
196 |
-
* @type boolean $required (optional) If a value is required default: true).
|
197 |
-
* @type string $delimiter (optional) The field delimiter (pipe or comma, default: | ).
|
198 |
-
* @type string $placeholder (optional) Defines the placeholder attribute.
|
199 |
-
* @type string $pattern (optional) Adds a regex pattern to the field (HTML5).
|
200 |
-
* @type string $title (optional) Defines the title attribute.
|
201 |
-
* @type string $min (optional) Adds a min attribute (HTML5).
|
202 |
-
* @type string $max (optional) Adds a max attribute (HTML5).
|
203 |
-
* @type string $rows (optional) Adds rows attribute to textarea.
|
204 |
-
* @type string $cols (optional) Adds cols attribute to textarea.
|
205 |
-
* }
|
206 |
-
* @param string $type The field type.
|
207 |
-
* @param string $value The default value for the field.
|
208 |
-
* @param string $valtochk Optional for comparing the default value of the field.
|
209 |
-
* @param string $class Optional for setting a specific CSS class for the field.
|
210 |
-
* @return string The HTML of the form field.
|
211 |
-
*/
|
212 |
-
//function wpmem_form_field( $args ) {
|
213 |
-
function wpmem_form_field( $name, $type=null, $value=null, $valtochk=null, $class='textbox' ) {
|
214 |
-
global $wpmem;
|
215 |
-
if ( is_array( $name ) ) {
|
216 |
-
$args = $name;
|
217 |
-
} else {
|
218 |
-
$args = array(
|
219 |
-
'name' => $name,
|
220 |
-
'type' => $type,
|
221 |
-
'value' => $value,
|
222 |
-
'compare' => $valtochk,
|
223 |
-
'class' => $class,
|
224 |
-
);
|
225 |
-
}
|
226 |
-
return $wpmem->forms->create_form_field( $args );
|
227 |
-
}
|
228 |
-
|
229 |
-
/**
|
230 |
-
* Wrapper for $wpmem->create_form_label().
|
231 |
-
*
|
232 |
-
* @since 3.1.7
|
233 |
-
*
|
234 |
-
* @global object $wpmem
|
235 |
-
* @param array $args {
|
236 |
-
* @type string $meta_key
|
237 |
-
* @type string $label
|
238 |
-
* @type string $type
|
239 |
-
* @type string $class (optional)
|
240 |
-
* @type string $required (optional)
|
241 |
-
* @type string $req_mark (optional)
|
242 |
-
* }
|
243 |
-
* @return string The HTML of the form label.
|
244 |
-
*/
|
245 |
-
function wpmem_form_label( $args ) {
|
246 |
-
global $wpmem;
|
247 |
-
return $wpmem->forms->create_form_label( $args );
|
248 |
-
}
|
249 |
-
|
250 |
-
/**
|
251 |
-
* Wrapper to get form fields.
|
252 |
-
*
|
253 |
-
* @since 3.1.1
|
254 |
-
* @since 3.1.5 Checks if fields array is set or empty before returning.
|
255 |
-
* @since 3.1.7 Added wpmem_form_fields filter.
|
256 |
-
*
|
257 |
-
* @global object $wpmem The WP_Members object.
|
258 |
-
* @param string $tag The action being used (default: null).
|
259 |
-
* @param string $form The form being generated.
|
260 |
-
* @return array $fields The form fields.
|
261 |
-
*/
|
262 |
-
function wpmem_fields( $tag = '', $form = 'default' ) {
|
263 |
-
global $wpmem;
|
264 |
-
// Load fields if none are loaded.
|
265 |
-
if ( ! isset( $wpmem->fields ) || empty( $wpmem->fields ) ) {
|
266 |
-
$wpmem->load_fields( $form );
|
267 |
-
}
|
268 |
-
|
269 |
-
// @todo Convert tag.
|
270 |
-
$tag = wpmem_convert_tag( $tag );
|
271 |
-
|
272 |
-
/**
|
273 |
-
* Filters the fields array.
|
274 |
-
*
|
275 |
-
* @since 3.1.7
|
276 |
-
*
|
277 |
-
* @param array $wpmem->fields
|
278 |
-
* @param string $tag (optional)
|
279 |
-
*/
|
280 |
-
return apply_filters( 'wpmem_fields', $wpmem->fields, $tag );
|
281 |
-
}
|
282 |
-
|
283 |
/**
|
284 |
* Wrapper to return a string from the get_text function.
|
285 |
*
|
@@ -315,73 +208,6 @@ function wpmem_use_custom_dialog( $defaults, $tag, $dialogs ) {
|
|
315 |
return $defaults;
|
316 |
}
|
317 |
|
318 |
-
/**
|
319 |
-
* Checks if user has a particular role.
|
320 |
-
*
|
321 |
-
* Utility function to check if a given user has a specific role. Users can
|
322 |
-
* have multiple roles assigned, so it checks the role array rather than using
|
323 |
-
* the incorrect method of current_user_can( 'role_name' ). The function can
|
324 |
-
* check the role of the current user (default) or a specific user (if $user_id
|
325 |
-
* is passed).
|
326 |
-
*
|
327 |
-
* @since 3.1.1
|
328 |
-
* @since 3.1.6 Include accepting an array of roles to check.
|
329 |
-
* @since 3.1.9 Return false if user is not logged in.
|
330 |
-
* @since 3.2.0 Change return false to not logged in AND no user id.
|
331 |
-
*
|
332 |
-
* @global object $current_user Current user object.
|
333 |
-
* @global object $wpmem WP_Members object.
|
334 |
-
* @param string|array $role Slug or array of slugs of the role being checked.
|
335 |
-
* @param int $user_id ID of the user being checked (optional).
|
336 |
-
* @return boolean $has_role True if user has the role, otherwise false.
|
337 |
-
*/
|
338 |
-
function wpmem_user_has_role( $role, $user_id = false ) {
|
339 |
-
if ( ! is_user_logged_in() && ! $user_id ) {
|
340 |
-
return false;
|
341 |
-
}
|
342 |
-
global $current_user, $wpmem;
|
343 |
-
$has_role = false;
|
344 |
-
if ( $user_id ) {
|
345 |
-
$user = get_userdata( $user_id );
|
346 |
-
}
|
347 |
-
if ( is_user_logged_in() && ! $user_id ) {
|
348 |
-
$user = ( isset( $current_user ) ) ? $current_user : wp_get_current_user();
|
349 |
-
}
|
350 |
-
if ( is_array( $role ) ) {
|
351 |
-
foreach ( $role as $r ) {
|
352 |
-
if ( in_array( $r, $user->roles ) ) {
|
353 |
-
return true;
|
354 |
-
}
|
355 |
-
}
|
356 |
-
} else {
|
357 |
-
return ( in_array( $role, $user->roles ) ) ? true : $has_role;
|
358 |
-
}
|
359 |
-
}
|
360 |
-
|
361 |
-
/**
|
362 |
-
* Checks if a user has a given meta value.
|
363 |
-
*
|
364 |
-
* @since 3.1.8
|
365 |
-
*
|
366 |
-
* @global object $wpmem WP_Members object.
|
367 |
-
* @param string $meta Meta key being checked.
|
368 |
-
* @param string $value Value the meta key should have (optional).
|
369 |
-
* @param int $user_id ID of the user being checked (optional).
|
370 |
-
* @return boolean $has_meta True if user has the meta value, otherwise false.
|
371 |
-
*/
|
372 |
-
function wpmem_user_has_meta( $meta, $value = false, $user_id = false ) {
|
373 |
-
global $wpmem;
|
374 |
-
$user_id = ( $user_id ) ? $user_id : get_current_user_id();
|
375 |
-
$has_meta = false;
|
376 |
-
$user_value = get_user_meta( $user_id, $meta, true );
|
377 |
-
if ( $value ) {
|
378 |
-
$has_meta = ( $user_value == $value ) ? true : $has_meta;
|
379 |
-
} else {
|
380 |
-
$has_meta = ( $value ) ? true : $has_meta;
|
381 |
-
}
|
382 |
-
return $has_meta;
|
383 |
-
}
|
384 |
-
|
385 |
/**
|
386 |
* Creates a membership number.
|
387 |
*
|
@@ -476,18 +302,6 @@ function wpmem_is_reg_page( $check = false ) {
|
|
476 |
return ( $check_page == $reg_page ) ? true : false;
|
477 |
}
|
478 |
|
479 |
-
/**
|
480 |
-
* Wrapper for load_dropins()
|
481 |
-
*
|
482 |
-
* @since 3.1.4
|
483 |
-
*
|
484 |
-
* @global object $wpmem The WP_Members object.
|
485 |
-
*/
|
486 |
-
function wpmem_load_dropins() {
|
487 |
-
global $wpmem;
|
488 |
-
$wpmem->load_dropins();
|
489 |
-
}
|
490 |
-
|
491 |
/**
|
492 |
* Creates a login/logout link.
|
493 |
*
|
@@ -524,79 +338,6 @@ function wpmem_loginout( $args = array(), $echo = false ) {
|
|
524 |
return $link;
|
525 |
}
|
526 |
|
527 |
-
/**
|
528 |
-
* Inserts array items at a specific point in an array.
|
529 |
-
*
|
530 |
-
* @since 3.1.6
|
531 |
-
*
|
532 |
-
* @param array $array Original array.
|
533 |
-
* @param array $new Array of new items to insert into $array.
|
534 |
-
* @param string $key Array key to insert new items before or after.
|
535 |
-
* @param string $loc Location to insert relative to $key (before|after) default:after.
|
536 |
-
* @return array Original array with new items inserted.
|
537 |
-
*/
|
538 |
-
function wpmem_array_insert( array $array, array $new, $key, $loc = 'after' ) {
|
539 |
-
$keys = array_keys( $array );
|
540 |
-
if ( 'before' == $loc ) {
|
541 |
-
$pos = (int) array_search( $key, $keys );
|
542 |
-
} else {
|
543 |
-
$index = array_search( $key, $keys );
|
544 |
-
$pos = ( false === $index ) ? count( $array ) : $index + 1;
|
545 |
-
}
|
546 |
-
return array_merge( array_slice( $array, 0, $pos ), $new, array_slice( $array, $pos ) );
|
547 |
-
}
|
548 |
-
|
549 |
-
/**
|
550 |
-
* Checks if a user is activated.
|
551 |
-
*
|
552 |
-
* @since 3.1.7
|
553 |
-
*
|
554 |
-
* @param int $user_id
|
555 |
-
* @return bool
|
556 |
-
*/
|
557 |
-
function wpmem_is_user_activated( $user_id = false ) {
|
558 |
-
$user_id = ( ! $user_id ) ? get_current_user_id() : $user_id;
|
559 |
-
$active = get_user_meta( $user_id, 'active', true );
|
560 |
-
return ( $active != 1 ) ? false : true;
|
561 |
-
}
|
562 |
-
|
563 |
-
/**
|
564 |
-
* Gets an array of the user's registration data.
|
565 |
-
*
|
566 |
-
* Returns an array keyed by meta keys of the user's registration data for
|
567 |
-
* all fields in the WP-Members Fields. Returns the current user unless
|
568 |
-
* a user ID is specified.
|
569 |
-
*
|
570 |
-
* @since 3.2.0
|
571 |
-
*
|
572 |
-
* @global object $wpmem
|
573 |
-
* @param integer $user_id
|
574 |
-
* @return array $user_fields
|
575 |
-
*/
|
576 |
-
function wpmem_user_data( $user_id = false ) {
|
577 |
-
global $wpmem;
|
578 |
-
return $wpmem->user_fields( $user_id );
|
579 |
-
}
|
580 |
-
|
581 |
-
/**
|
582 |
-
* Updates a user's role.
|
583 |
-
*
|
584 |
-
* This is a wrapper for $wpmem->update_user_role(). It can add a role to a
|
585 |
-
* user, change or remove the user's role. If no action is specified it will
|
586 |
-
* change the role.
|
587 |
-
*
|
588 |
-
* @since 3.2.0
|
589 |
-
*
|
590 |
-
* @global object $wpmem
|
591 |
-
* @param integer $user_id (required)
|
592 |
-
* @param string $role (required)
|
593 |
-
* @param string $action (optional add|remove|set default:set)
|
594 |
-
*/
|
595 |
-
function wpmem_update_user_role( $user_id, $role, $action = 'set' ) {
|
596 |
-
global $wpmem;
|
597 |
-
$wpmem->user->update_user_role( $user_id, $role, $action );
|
598 |
-
}
|
599 |
-
|
600 |
/**
|
601 |
* Dispalays requested dialog.
|
602 |
*
|
@@ -612,34 +353,4 @@ function wpmem_display_message( $tag, $echo = true ) {
|
|
612 |
}
|
613 |
}
|
614 |
|
615 |
-
/**
|
616 |
-
* A function for checking user access criteria.
|
617 |
-
*
|
618 |
-
* @since 3.2.0
|
619 |
-
*
|
620 |
-
* @param integer $user_id User ID (optional|default: false).
|
621 |
-
* @return boolean $access If user has access.
|
622 |
-
*/
|
623 |
-
function wpmem_user_has_access( $user_id = false, $product = false ) {
|
624 |
-
global $wpmem;
|
625 |
-
|
626 |
-
$user_id = ( ! $user_id ) ? get_current_user_id() : $user_id;
|
627 |
-
$access = ( is_user_logged_in() ) ? true : false;
|
628 |
-
|
629 |
-
// @todo
|
630 |
-
$access = ( ! $wpmem->user->has_access( $product, $user_id ) ) ? true : $access;
|
631 |
-
|
632 |
-
/**
|
633 |
-
* Filter the access result.
|
634 |
-
*
|
635 |
-
* @since 3.2.0
|
636 |
-
*
|
637 |
-
* @param boolean $access
|
638 |
-
* @param integer $user_id
|
639 |
-
* @param array $args
|
640 |
-
*/
|
641 |
-
$access = apply_filters( 'wpmem_user_has_access', $access, $user_id );
|
642 |
-
return $access;
|
643 |
-
}
|
644 |
-
|
645 |
// End of file.
|
19 |
* - wpmem_register_url
|
20 |
* - wpmem_profile_url
|
21 |
* - wpmem_current_url
|
|
|
|
|
|
|
22 |
* - wpmem_gettext
|
23 |
* - wpmem_use_custom_dialog
|
|
|
24 |
* - wpmem_create_membership_number
|
25 |
* - wpmem_login_status
|
26 |
* - wpmem_get
|
27 |
* - wpmem_is_reg_page
|
|
|
28 |
* - wpmem_loginout
|
|
|
29 |
* - wpmem_is_user_activated
|
30 |
* - wpmem_current_post_id
|
31 |
* - wpmem_user_data
|
32 |
* - wpmem_update_user_role
|
33 |
* - wpmem_display_message
|
|
|
34 |
*/
|
35 |
|
36 |
// Exit if accessed directly.
|
173 |
return url_to_postid( wpmem_current_url() );
|
174 |
}
|
175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
/**
|
177 |
* Wrapper to return a string from the get_text function.
|
178 |
*
|
208 |
return $defaults;
|
209 |
}
|
210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
/**
|
212 |
* Creates a membership number.
|
213 |
*
|
302 |
return ( $check_page == $reg_page ) ? true : false;
|
303 |
}
|
304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
/**
|
306 |
* Creates a login/logout link.
|
307 |
*
|
338 |
return $link;
|
339 |
}
|
340 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
341 |
/**
|
342 |
* Dispalays requested dialog.
|
343 |
*
|
353 |
}
|
354 |
}
|
355 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
// End of file.
|
inc/class-wp-members-forms.php
CHANGED
@@ -834,7 +834,7 @@ class WP_Members_Forms {
|
|
834 |
}
|
835 |
|
836 |
// Gets the field value for edit profile.
|
837 |
-
if ( ( 'edit' == $tag ) && ( '' == $wpmem->regchk ) ) {
|
838 |
switch ( $meta_key ) {
|
839 |
case( 'description' ):
|
840 |
case( 'textarea' == $field['type'] ):
|
@@ -1062,7 +1062,8 @@ class WP_Members_Forms {
|
|
1062 |
*/
|
1063 |
$rows = apply_filters( 'wpmem_register_form_rows', $rows, $tag );
|
1064 |
|
1065 |
-
// Make sure all keys are set.
|
|
|
1066 |
$row_keys = array( 'meta', 'type', 'value', 'values', 'label_text', 'row_before', 'label', 'field_before', 'field', 'field_after', 'row_after' );
|
1067 |
foreach ( $rows as $meta_key => $row ) {
|
1068 |
foreach ( $row_keys as $check_key ) {
|
834 |
}
|
835 |
|
836 |
// Gets the field value for edit profile.
|
837 |
+
if ( ( 'edit' == $tag ) && ( '' == $wpmem->regchk ) ) {
|
838 |
switch ( $meta_key ) {
|
839 |
case( 'description' ):
|
840 |
case( 'textarea' == $field['type'] ):
|
1062 |
*/
|
1063 |
$rows = apply_filters( 'wpmem_register_form_rows', $rows, $tag );
|
1064 |
|
1065 |
+
// Make sure all keys are set just in case someone didn't return a proper array through the filter.
|
1066 |
+
// @todo Merge this with the next foreach loop so we only have to foreach one time.
|
1067 |
$row_keys = array( 'meta', 'type', 'value', 'values', 'label_text', 'row_before', 'label', 'field_before', 'field', 'field_after', 'row_after' );
|
1068 |
foreach ( $rows as $meta_key => $row ) {
|
1069 |
foreach ( $row_keys as $check_key ) {
|
inc/class-wp-members-products.php
CHANGED
@@ -54,68 +54,52 @@ class WP_Members_Products {
|
|
54 |
* Sets up custom access restriction by product.
|
55 |
*
|
56 |
* @since 3.2.0
|
|
|
57 |
*
|
|
|
58 |
* @global object $wpmem
|
59 |
* @param string $content
|
60 |
* @return string $content
|
61 |
*/
|
62 |
function product_access( $content ) {
|
63 |
|
64 |
-
global $wpmem;
|
65 |
-
// Is the user logged in and is this blocked content?
|
66 |
-
if ( is_user_logged_in() && wpmem_is_blocked() ) {
|
67 |
-
$access = $this->check_product_access();
|
68 |
-
// Handle content.
|
69 |
-
$content = ( $access ) ? $content : $wpmem->get_text( 'product_restricted' );
|
70 |
-
// Handle comments.
|
71 |
-
if ( ! $access ) {
|
72 |
-
add_filter( 'wpmem_securify_comments', '__return_false' );
|
73 |
-
}
|
74 |
-
}
|
75 |
-
// Return unfiltered content for all other cases.
|
76 |
-
return $content;
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Checks access restriction by product.
|
81 |
-
*
|
82 |
-
* @since 3.2.0
|
83 |
-
*
|
84 |
-
* @global object $post
|
85 |
-
* @global object $wpmem
|
86 |
-
* @return boolean true if user has access, otherwise false.
|
87 |
-
*/
|
88 |
-
function check_product_access() {
|
89 |
-
|
90 |
global $post, $wpmem;
|
91 |
// Is the user logged in and is this blocked content?
|
92 |
if ( is_user_logged_in() && wpmem_is_blocked() ) {
|
|
|
93 |
// Get the post access products.
|
94 |
$post_products = get_post_meta( $post->ID, $wpmem->membership->post_meta, true );
|
95 |
// If the post is restricted to a product.
|
96 |
if ( $post_products ) {
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
* @since 3.2.0
|
103 |
-
*
|
104 |
-
* @param boolean $user_has_access
|
105 |
-
*/
|
106 |
-
$user_has_access = apply_filters( 'wpmem_user_has_access', $wpmem->user->has_access( $post_products ) );
|
107 |
-
if ( $user_has_access ) {
|
108 |
-
return true;
|
109 |
}
|
110 |
-
// The error message for invalid users.
|
111 |
-
return false;
|
112 |
} else {
|
113 |
// Content that has no product restriction.
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
}
|
116 |
}
|
117 |
// Return unfiltered content for all other cases.
|
118 |
-
return
|
119 |
}
|
120 |
|
121 |
/**
|
54 |
* Sets up custom access restriction by product.
|
55 |
*
|
56 |
* @since 3.2.0
|
57 |
+
* @since 3.2.2 Merged check_product_access() logic for better messaging.
|
58 |
*
|
59 |
+
* @global object $post
|
60 |
* @global object $wpmem
|
61 |
* @param string $content
|
62 |
* @return string $content
|
63 |
*/
|
64 |
function product_access( $content ) {
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
global $post, $wpmem;
|
67 |
// Is the user logged in and is this blocked content?
|
68 |
if ( is_user_logged_in() && wpmem_is_blocked() ) {
|
69 |
+
|
70 |
// Get the post access products.
|
71 |
$post_products = get_post_meta( $post->ID, $wpmem->membership->post_meta, true );
|
72 |
// If the post is restricted to a product.
|
73 |
if ( $post_products ) {
|
74 |
+
if ( wpmem_user_has_access( $post_products ) ) {
|
75 |
+
$access = true;
|
76 |
+
} else {
|
77 |
+
// The error message for invalid users.
|
78 |
+
$access = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
|
|
|
|
80 |
} else {
|
81 |
// Content that has no product restriction.
|
82 |
+
$access = true;
|
83 |
+
}
|
84 |
+
|
85 |
+
// Handle content.
|
86 |
+
/**
|
87 |
+
* Filter the product restricted message.
|
88 |
+
*
|
89 |
+
* @since 3.2.3
|
90 |
+
*
|
91 |
+
* @param string The message.
|
92 |
+
* @param array $post_products Post products array.
|
93 |
+
*/
|
94 |
+
$content = ( $access ) ? $content : apply_filters( 'wpmem_product_restricted_msg', $wpmem->get_text( 'product_restricted' ), $post_products );
|
95 |
+
|
96 |
+
// Handle comments.
|
97 |
+
if ( ! $access ) {
|
98 |
+
add_filter( 'wpmem_securify_comments', '__return_false' );
|
99 |
}
|
100 |
}
|
101 |
// Return unfiltered content for all other cases.
|
102 |
+
return $content;
|
103 |
}
|
104 |
|
105 |
/**
|
inc/class-wp-members-shortcodes.php
CHANGED
@@ -181,7 +181,7 @@ class WP_Members_Shortcodes {
|
|
181 |
// Fixes the wptexturize.
|
182 |
remove_filter( 'the_content', 'wpautop' );
|
183 |
remove_filter( 'the_content', 'wptexturize' );
|
184 |
-
add_filter( 'the_content', '
|
185 |
}
|
186 |
} // End texturize functions
|
187 |
}
|
@@ -198,6 +198,7 @@ class WP_Members_Shortcodes {
|
|
198 |
* @since 3.0.0
|
199 |
* @since 3.2.0 Moved to WP_Members_Shortcodes::logged_in().
|
200 |
* @since 3.2.0 Added attributes for meta key/value pairs.
|
|
|
201 |
*
|
202 |
* @global object $wpmem The WP_Members object.
|
203 |
*
|
@@ -275,6 +276,13 @@ class WP_Members_Shortcodes {
|
|
275 |
$do_return = true;
|
276 |
}
|
277 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
|
279 |
// Prevents display if the current page is the user profile and an action is being handled.
|
280 |
if ( ( wpmem_current_url( true, false ) == wpmem_profile_url() ) && isset( $_GET['a'] ) ) {
|
@@ -356,7 +364,6 @@ class WP_Members_Shortcodes {
|
|
356 |
*
|
357 |
* @global object $wpmem The WP_Members object.
|
358 |
* @global string $wpmem_themsg The WP-Members message container.
|
359 |
-
*
|
360 |
* @param string $atts {
|
361 |
* The shortcode attributes.
|
362 |
*
|
@@ -378,7 +385,7 @@ class WP_Members_Shortcodes {
|
|
378 |
|
379 |
if ( $wpmem->regchk == "captcha" ) {
|
380 |
global $wpmem_captcha_err;
|
381 |
-
$wpmem_themsg =
|
382 |
}
|
383 |
|
384 |
if ( $wpmem->regchk == "loginfailed" ) {
|
181 |
// Fixes the wptexturize.
|
182 |
remove_filter( 'the_content', 'wpautop' );
|
183 |
remove_filter( 'the_content', 'wptexturize' );
|
184 |
+
add_filter( 'the_content', array( 'WP_Members', 'texturize' ), 999 );
|
185 |
}
|
186 |
} // End texturize functions
|
187 |
}
|
198 |
* @since 3.0.0
|
199 |
* @since 3.2.0 Moved to WP_Members_Shortcodes::logged_in().
|
200 |
* @since 3.2.0 Added attributes for meta key/value pairs.
|
201 |
+
* @since 3.2.3 Added product attribute.
|
202 |
*
|
203 |
* @global object $wpmem The WP_Members object.
|
204 |
*
|
276 |
$do_return = true;
|
277 |
}
|
278 |
}
|
279 |
+
|
280 |
+
// If there is a product attribute.
|
281 |
+
if ( isset( $atts['product'] ) ) {
|
282 |
+
if ( wpmem_user_has_access( 'product' ) ) {
|
283 |
+
$do_return = true;
|
284 |
+
}
|
285 |
+
}
|
286 |
|
287 |
// Prevents display if the current page is the user profile and an action is being handled.
|
288 |
if ( ( wpmem_current_url( true, false ) == wpmem_profile_url() ) && isset( $_GET['a'] ) ) {
|
364 |
*
|
365 |
* @global object $wpmem The WP_Members object.
|
366 |
* @global string $wpmem_themsg The WP-Members message container.
|
|
|
367 |
* @param string $atts {
|
368 |
* The shortcode attributes.
|
369 |
*
|
385 |
|
386 |
if ( $wpmem->regchk == "captcha" ) {
|
387 |
global $wpmem_captcha_err;
|
388 |
+
$wpmem_themsg = $wpmem->get_text( 'reg_captcha_err' ) . '<br /><br />' . $wpmem_captcha_err;
|
389 |
}
|
390 |
|
391 |
if ( $wpmem->regchk == "loginfailed" ) {
|
inc/class-wp-members-user-profile.php
CHANGED
@@ -31,7 +31,8 @@ class WP_Members_User_Profile {
|
|
31 |
|
32 |
global $current_screen, $user_ID, $wpmem;
|
33 |
$user_id = ( 'profile' == $current_screen->id ) ? $user_ID : filter_var( $_REQUEST['user_id'], FILTER_SANITIZE_NUMBER_INT );
|
34 |
-
$display = ( 'profile' == $current_screen->base ) ? 'user' : 'admin';
|
|
|
35 |
|
36 |
<h3><?php
|
37 |
$heading = ( 'admin' == $display ) ? __( 'WP-Members Additional Fields', 'wp-members' ) : __( 'Additional Information', 'wp-members' );
|
31 |
|
32 |
global $current_screen, $user_ID, $wpmem;
|
33 |
$user_id = ( 'profile' == $current_screen->id ) ? $user_ID : filter_var( $_REQUEST['user_id'], FILTER_SANITIZE_NUMBER_INT );
|
34 |
+
$display = ( 'profile' == $current_screen->base ) ? 'user' : 'admin';
|
35 |
+
$display = ( current_user_can( 'edit_users' ) ) ? 'admin' : $display; ?>
|
36 |
|
37 |
<h3><?php
|
38 |
$heading = ( 'admin' == $display ) ? __( 'WP-Members Additional Fields', 'wp-members' ) : __( 'Additional Information', 'wp-members' );
|
inc/class-wp-members-user.php
CHANGED
@@ -60,25 +60,24 @@ class WP_Members_User {
|
|
60 |
* wrapper and is the direct function called for login.
|
61 |
*
|
62 |
* @since 3.1.7
|
|
|
|
|
|
|
63 |
*
|
64 |
* @return string Returns "loginfailed" if failed login.
|
65 |
*/
|
66 |
function login() {
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
*/
|
76 |
-
$creds = apply_filters( 'wpmem_login_fields', $creds );
|
77 |
-
foreach ( $creds as $key => $val ) {
|
78 |
-
$creds[ $key ] = ( 'user_login' == $key ) ? sanitize_user( wpmem_get( $val ) ) : wpmem_get( $val );
|
79 |
}
|
80 |
|
81 |
-
$user = wp_signon(
|
82 |
|
83 |
if ( is_wp_error( $user ) ) {
|
84 |
return "loginfailed";
|
@@ -103,7 +102,7 @@ class WP_Members_User {
|
|
103 |
* @param int $user->ID The user's primary key ID.
|
104 |
*/
|
105 |
$redirect_to = apply_filters( 'wpmem_login_redirect', $redirect_to, $user->ID );
|
106 |
-
|
107 |
exit();
|
108 |
}
|
109 |
}
|
@@ -456,6 +455,18 @@ class WP_Members_User {
|
|
456 |
}
|
457 |
}
|
458 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
/**
|
460 |
* Sets user as logged on password change.
|
461 |
*
|
@@ -463,15 +474,10 @@ class WP_Members_User {
|
|
463 |
*
|
464 |
* @since 3.2.0
|
465 |
*
|
466 |
-
* @global object $user
|
467 |
* @param int $user_id
|
468 |
* @param string $password
|
469 |
*/
|
470 |
-
function set_as_logged_in( $user_id
|
471 |
-
global $user;
|
472 |
-
// Update user password.
|
473 |
-
wp_set_password( $password, $user_id );
|
474 |
-
// Maintain login state.
|
475 |
$user = get_user_by( 'id', $user_id );
|
476 |
wp_set_current_user( $user_id, $user->user_login );
|
477 |
wp_set_auth_cookie( $user_id );
|
@@ -485,30 +491,50 @@ class WP_Members_User {
|
|
485 |
* @global object $wpmem
|
486 |
* @param mixed $product
|
487 |
* @param int $user_id (optional)
|
488 |
-
* @return bool
|
489 |
*/
|
490 |
function has_access( $product, $user_id = false ) {
|
491 |
global $wpmem;
|
492 |
-
|
|
|
|
|
|
|
|
|
493 |
foreach ( $product as $prod ) {
|
494 |
if ( isset( $this->access[ $prod ] ) ) {
|
495 |
// Is this an expiration product?
|
496 |
if ( isset( $wpmem->membership->product_detail[ $prod ]['expires'][0] ) && ! is_bool( $this->access[ $prod ] ) ) {
|
497 |
if ( $this->is_current( $this->access[ $prod ] ) ) {
|
498 |
-
|
|
|
499 |
}
|
500 |
} elseif ( '' != $wpmem->membership->product_detail[ $prod ]['role'] ) {
|
501 |
if ( $this->access[ $prod ] && wpmem_user_has_role( $wpmem->membership->product_detail[ $prod ]['role'] ) ) {
|
502 |
-
|
|
|
503 |
}
|
504 |
} else {
|
505 |
if ( $this->access[ $prod ] ) {
|
506 |
-
|
|
|
507 |
}
|
508 |
}
|
509 |
}
|
510 |
}
|
511 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
512 |
}
|
513 |
|
514 |
/**
|
@@ -547,7 +573,7 @@ class WP_Members_User {
|
|
547 |
}
|
548 |
|
549 |
// Convert date to add.
|
550 |
-
$expires = $wpmem->membership->product_detail[ $product ]['expires'];
|
551 |
|
552 |
if ( is_array( $expires ) ) {
|
553 |
$add_date = explode( "|", $wpmem->membership->product_detail[ $product ]['expires'][0] );
|
@@ -584,14 +610,30 @@ class WP_Members_User {
|
|
584 |
/**
|
585 |
* Utility for expiration validation.
|
586 |
*
|
587 |
-
* @3.2.0
|
|
|
|
|
588 |
*/
|
589 |
function is_current( $date ) {
|
590 |
return ( time() < strtotime( $date ) ) ? true : false;
|
591 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
592 |
|
593 |
/**
|
594 |
-
* Checks if a user is activated.
|
595 |
*
|
596 |
* @since 2.7.1
|
597 |
* @since 3.2.0 Moved from core to user object.
|
@@ -610,7 +652,7 @@ class WP_Members_User {
|
|
610 |
}
|
611 |
|
612 |
// Activation flag must be validated.
|
613 |
-
if ( !
|
614 |
return new WP_Error( 'authentication_failed', __( '<strong>ERROR</strong>: User has not been activated.', 'wp-members' ) );
|
615 |
}
|
616 |
|
60 |
* wrapper and is the direct function called for login.
|
61 |
*
|
62 |
* @since 3.1.7
|
63 |
+
* @since 3.2.3 Removed wpmem_login_fields filter.
|
64 |
+
* @since 3.2.3 Replaced form collection with WP script to facilitate login with username OR email.
|
65 |
+
* @since 3.2.3 Changed to wp_safe_redirect().
|
66 |
*
|
67 |
* @return string Returns "loginfailed" if failed login.
|
68 |
*/
|
69 |
function login() {
|
70 |
|
71 |
+
if ( ! empty( $_POST['log'] ) && ! force_ssl_admin() ) {
|
72 |
+
$user_name = sanitize_user( $_POST['log'] );
|
73 |
+
$user = get_user_by( 'login', $user_name );
|
74 |
+
|
75 |
+
if ( ! $user && strpos( $user_name, '@' ) ) {
|
76 |
+
$user = get_user_by( 'email', $user_name );
|
77 |
+
}
|
|
|
|
|
|
|
|
|
78 |
}
|
79 |
|
80 |
+
$user = wp_signon( array(), is_ssl() );
|
81 |
|
82 |
if ( is_wp_error( $user ) ) {
|
83 |
return "loginfailed";
|
102 |
* @param int $user->ID The user's primary key ID.
|
103 |
*/
|
104 |
$redirect_to = apply_filters( 'wpmem_login_redirect', $redirect_to, $user->ID );
|
105 |
+
wp_safe_redirect( $redirect_to );
|
106 |
exit();
|
107 |
}
|
108 |
}
|
455 |
}
|
456 |
}
|
457 |
|
458 |
+
/**
|
459 |
+
* Sets a user's password.
|
460 |
+
*
|
461 |
+
* @since 3.2.3
|
462 |
+
*
|
463 |
+
* @param int $user_id
|
464 |
+
* @param string $password
|
465 |
+
*/
|
466 |
+
function set_password( $user_id, $password ) {
|
467 |
+
wp_set_password( $password, $user_id );
|
468 |
+
}
|
469 |
+
|
470 |
/**
|
471 |
* Sets user as logged on password change.
|
472 |
*
|
474 |
*
|
475 |
* @since 3.2.0
|
476 |
*
|
|
|
477 |
* @param int $user_id
|
478 |
* @param string $password
|
479 |
*/
|
480 |
+
function set_as_logged_in( $user_id ) {
|
|
|
|
|
|
|
|
|
481 |
$user = get_user_by( 'id', $user_id );
|
482 |
wp_set_current_user( $user_id, $user->user_login );
|
483 |
wp_set_auth_cookie( $user_id );
|
491 |
* @global object $wpmem
|
492 |
* @param mixed $product
|
493 |
* @param int $user_id (optional)
|
494 |
+
* @return bool $access
|
495 |
*/
|
496 |
function has_access( $product, $user_id = false ) {
|
497 |
global $wpmem;
|
498 |
+
if ( ! is_user_logged_in() ) {
|
499 |
+
return false;
|
500 |
+
}
|
501 |
+
$user_id = ( ! $user_id ) ? get_current_user_id() : $user_id; //echo '<pre>'; global $wpmem; print_r( $wpmem );
|
502 |
+
$access = false;
|
503 |
foreach ( $product as $prod ) {
|
504 |
if ( isset( $this->access[ $prod ] ) ) {
|
505 |
// Is this an expiration product?
|
506 |
if ( isset( $wpmem->membership->product_detail[ $prod ]['expires'][0] ) && ! is_bool( $this->access[ $prod ] ) ) {
|
507 |
if ( $this->is_current( $this->access[ $prod ] ) ) {
|
508 |
+
$access = true;
|
509 |
+
break;
|
510 |
}
|
511 |
} elseif ( '' != $wpmem->membership->product_detail[ $prod ]['role'] ) {
|
512 |
if ( $this->access[ $prod ] && wpmem_user_has_role( $wpmem->membership->product_detail[ $prod ]['role'] ) ) {
|
513 |
+
$access = true;
|
514 |
+
break;
|
515 |
}
|
516 |
} else {
|
517 |
if ( $this->access[ $prod ] ) {
|
518 |
+
$access = true;
|
519 |
+
break;
|
520 |
}
|
521 |
}
|
522 |
}
|
523 |
}
|
524 |
+
|
525 |
+
/**
|
526 |
+
* Filter the access result.
|
527 |
+
*
|
528 |
+
* @since 3.2.0
|
529 |
+
* @since 3.2.3 Added $product argument.
|
530 |
+
*
|
531 |
+
* @param boolean $access
|
532 |
+
* @param mixed $product
|
533 |
+
* @param integer $user_id
|
534 |
+
* @param array $args
|
535 |
+
*/
|
536 |
+
return apply_filters( 'wpmem_user_has_access', $access, $product, $user_id );
|
537 |
+
|
538 |
}
|
539 |
|
540 |
/**
|
573 |
}
|
574 |
|
575 |
// Convert date to add.
|
576 |
+
$expires = ( isset( $wpmem->membership->product_detail[ $product ]['expires'] ) ) ? $wpmem->membership->product_detail[ $product ]['expires'] : false;
|
577 |
|
578 |
if ( is_array( $expires ) ) {
|
579 |
$add_date = explode( "|", $wpmem->membership->product_detail[ $product ]['expires'][0] );
|
610 |
/**
|
611 |
* Utility for expiration validation.
|
612 |
*
|
613 |
+
* @since 3.2.0
|
614 |
+
*
|
615 |
+
* @param date $date
|
616 |
*/
|
617 |
function is_current( $date ) {
|
618 |
return ( time() < strtotime( $date ) ) ? true : false;
|
619 |
}
|
620 |
+
|
621 |
+
/**
|
622 |
+
* Check if a user is activated.
|
623 |
+
*
|
624 |
+
* @since 3.2.2
|
625 |
+
*
|
626 |
+
* @param int $user_id
|
627 |
+
* @return bool $active
|
628 |
+
*/
|
629 |
+
function is_user_activated( $user_id = false ) {
|
630 |
+
$user_id = ( ! $user_id ) ? get_current_user_id() : $user_id;
|
631 |
+
$active = get_user_meta( $user_id, 'active', true );
|
632 |
+
return ( $active != 1 ) ? false : true;
|
633 |
+
}
|
634 |
|
635 |
/**
|
636 |
+
* Checks if a user is activated during user authentication.
|
637 |
*
|
638 |
* @since 2.7.1
|
639 |
* @since 3.2.0 Moved from core to user object.
|
652 |
}
|
653 |
|
654 |
// Activation flag must be validated.
|
655 |
+
if ( ! $this->is_user_activated( $user->ID ) ) {
|
656 |
return new WP_Error( 'authentication_failed', __( '<strong>ERROR</strong>: User has not been activated.', 'wp-members' ) );
|
657 |
}
|
658 |
|
inc/class-wp-members.php
CHANGED
@@ -321,28 +321,31 @@ class WP_Members {
|
|
321 |
add_action( 'admin_menu', 'wpmem_admin_options' ); // adds admin menu
|
322 |
add_action( 'user_register', 'wpmem_wp_reg_finalize' ); // handles wp native registration
|
323 |
add_action( 'login_enqueue_scripts', 'wpmem_wplogin_stylesheet' ); // styles the native registration
|
324 |
-
add_action( 'wp_enqueue_scripts', '
|
325 |
add_action( 'wp_enqueue_scripts', array( $this, 'loginout_script' ) );
|
326 |
add_action( 'init', array( $this->membership, 'add_cpt' ), 0 ); // Adds membership plans custom post type.
|
327 |
-
add_action( 'wpmem_pwd_change', array( $this->user, '
|
|
|
328 |
add_action( 'pre_get_posts', array( $this, 'do_hide_posts' ) );
|
329 |
add_action( 'customize_register', array( $this, 'customizer_settings' ) );
|
330 |
|
331 |
// Add filters.
|
332 |
add_filter( 'the_content', array( $this, 'do_securify' ), 99 );
|
333 |
-
add_filter( 'allow_password_reset', '
|
334 |
-
add_filter( 'register_form', 'wpmem_wp_register_form' );
|
335 |
add_action( 'woocommerce_register_form', 'wpmem_woo_register_form' );
|
336 |
-
add_filter( 'registration_errors', 'wpmem_wp_reg_validate', 10, 3 );
|
337 |
add_filter( 'comments_open', array( $this, 'do_securify_comments' ), 99 ); // securifies the comments
|
338 |
-
add_filter( 'wpmem_securify', array( $this, 'reg_securify' ) );
|
339 |
-
add_filter( 'query_vars', array( $this, 'add_query_vars' ), 10, 2 );
|
340 |
add_filter( 'get_pages', array( $this, 'filter_get_pages' ) );
|
341 |
add_filter( 'wp_get_nav_menu_items', array( $this, 'filter_nav_menu_items' ), null, 3 );
|
|
|
|
|
342 |
|
343 |
// If registration is moderated, check for activation (blocks backend login by non-activated users).
|
344 |
if ( $this->mod_reg == 1 ) {
|
345 |
-
add_filter( 'authenticate', '
|
346 |
}
|
347 |
|
348 |
/**
|
@@ -407,21 +410,21 @@ class WP_Members {
|
|
407 |
* @since 3.0.0
|
408 |
*/
|
409 |
function load_constants() {
|
410 |
-
( ! defined( 'WPMEM_BLOCK_POSTS' ) ) ? define( 'WPMEM_BLOCK_POSTS', $this->block['post'] ) : '';
|
411 |
-
( ! defined( 'WPMEM_BLOCK_PAGES' ) ) ? define( 'WPMEM_BLOCK_PAGES', $this->block['page'] ) : '';
|
412 |
-
( ! defined( 'WPMEM_SHOW_EXCERPT' ) ) ? define( 'WPMEM_SHOW_EXCERPT', $this->show_excerpt['post'] ) : '';
|
413 |
-
( ! defined( 'WPMEM_NOTIFY_ADMIN' ) ) ? define( 'WPMEM_NOTIFY_ADMIN', $this->notify ) : '';
|
414 |
-
( ! defined( 'WPMEM_MOD_REG' ) ) ? define( 'WPMEM_MOD_REG', $this->mod_reg ) : '';
|
415 |
-
( ! defined( 'WPMEM_CAPTCHA' ) ) ? define( 'WPMEM_CAPTCHA', $this->captcha ) : '';
|
416 |
-
( ! defined( 'WPMEM_NO_REG' ) ) ? define( 'WPMEM_NO_REG', ( -1 * $this->show_reg['post'] ) ) : '';
|
417 |
( ! defined( 'WPMEM_USE_EXP' ) ) ? define( 'WPMEM_USE_EXP', $this->use_exp ) : '';
|
418 |
( ! defined( 'WPMEM_USE_TRL' ) ) ? define( 'WPMEM_USE_TRL', $this->use_trial ) : '';
|
419 |
-
( ! defined( 'WPMEM_IGNORE_WARN' ) ) ? define( 'WPMEM_IGNORE_WARN', $this->warnings ) : '';
|
|
|
|
|
|
|
|
|
420 |
|
421 |
-
( ! defined( 'WPMEM_MSURL' ) ) ? define( 'WPMEM_MSURL', $this->user_pages['profile'] ) : '';
|
422 |
-
( ! defined( 'WPMEM_REGURL' ) ) ? define( 'WPMEM_REGURL', $this->user_pages['register'] ) : '';
|
423 |
-
( ! defined( 'WPMEM_LOGURL' ) ) ? define( 'WPMEM_LOGURL', $this->user_pages['login'] ) : '';
|
424 |
-
|
425 |
( ! defined( 'WPMEM_DROPIN_DIR' ) ) ? define( 'WPMEM_DROPIN_DIR', WP_PLUGIN_DIR . '/wp-members-dropins/' ) : '';
|
426 |
|
427 |
define( 'WPMEM_CSSURL', $this->cssurl );
|
@@ -457,18 +460,21 @@ class WP_Members {
|
|
457 |
require_once( WPMEM_PATH . 'inc/class-wp-members-widget.php' );
|
458 |
require_once( WPMEM_PATH . 'inc/class-wp-members-products.php' );
|
459 |
require_once( WPMEM_PATH . 'inc/class-wp-members-shortcodes.php' );
|
460 |
-
require_once( WPMEM_PATH . 'inc/core.php' );
|
461 |
require_once( WPMEM_PATH . 'inc/api.php' );
|
|
|
462 |
require_once( WPMEM_PATH . 'inc/api-forms.php' );
|
463 |
-
require_once( WPMEM_PATH . 'inc/
|
|
|
464 |
require_once( WPMEM_PATH . 'inc/forms.php' );
|
465 |
require_once( WPMEM_PATH . 'inc/dialogs.php' );
|
|
|
|
|
|
|
|
|
466 |
//require_once( WPMEM_PATH . 'inc/sidebar.php' ); // @deprecated 3.2.0
|
467 |
//require_once( WPMEM_PATH . 'inc/shortcodes.php' ); // @deprecated 3.2.0
|
468 |
//require_once( WPMEM_PATH . 'inc/email.php' ); // @deprecated 3.2.0
|
469 |
-
include_once( WPMEM_PATH . 'inc/wp-registration.php' );
|
470 |
//require_once( WPMEM_PATH . 'inc/users.php' ); // @deprecated 3.1.9
|
471 |
-
require_once( WPMEM_PATH . 'inc/deprecated.php' );
|
472 |
|
473 |
}
|
474 |
|
@@ -559,8 +565,8 @@ class WP_Members {
|
|
559 |
|
560 |
case 'pwdchange':
|
561 |
$regchk = $this->user->password_update( 'change' );
|
562 |
-
|
563 |
-
|
564 |
case 'pwdreset':
|
565 |
$regchk = $this->user->password_update( 'reset' );
|
566 |
break;
|
@@ -694,14 +700,15 @@ class WP_Members {
|
|
694 |
*
|
695 |
* @since 3.0.0
|
696 |
*
|
697 |
-
* @global string $wpmem_themsg Contains messages to be output.
|
698 |
* @global object $post The WordPress Post object.
|
|
|
|
|
699 |
* @param string $content
|
700 |
* @return string $content
|
701 |
*/
|
702 |
function do_securify( $content = null ) {
|
703 |
|
704 |
-
global $
|
705 |
|
706 |
$content = ( is_single() || is_page() ) ? $content : wpmem_do_excerpt( $content );
|
707 |
|
@@ -709,7 +716,7 @@ class WP_Members {
|
|
709 |
|
710 |
if ( $this->regchk == "captcha" ) {
|
711 |
global $wpmem_captcha_err;
|
712 |
-
$wpmem_themsg =
|
713 |
}
|
714 |
|
715 |
// Block/unblock Posts.
|
@@ -799,7 +806,7 @@ class WP_Members {
|
|
799 |
// Fix the wptexturize.
|
800 |
remove_filter( 'the_content', 'wpautop' );
|
801 |
remove_filter( 'the_content', 'wptexturize' );
|
802 |
-
add_filter( 'the_content', '
|
803 |
}
|
804 |
|
805 |
return $content;
|
@@ -886,7 +893,7 @@ class WP_Members {
|
|
886 |
global $wpdb;
|
887 |
$hidden = get_transient( '_wpmem_hidden_posts' );
|
888 |
if ( false === $hidden ) {
|
889 |
-
$this->update_hidden_posts();
|
890 |
}
|
891 |
return $hidden;
|
892 |
}
|
@@ -897,6 +904,7 @@ class WP_Members {
|
|
897 |
* @since 3.2.0
|
898 |
*
|
899 |
* @global object $wpdb
|
|
|
900 |
*/
|
901 |
function update_hidden_posts() {
|
902 |
global $wpdb;
|
@@ -906,6 +914,7 @@ class WP_Members {
|
|
906 |
$hidden[] = $result->post_id;
|
907 |
}
|
908 |
set_transient( '_wpmem_hidden_posts', $hidden, 60*5 );
|
|
|
909 |
}
|
910 |
|
911 |
/**
|
@@ -1005,6 +1014,25 @@ class WP_Members {
|
|
1005 |
return $items;
|
1006 |
}
|
1007 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1008 |
/**
|
1009 |
* Sets the registration fields.
|
1010 |
*
|
@@ -1168,6 +1196,16 @@ class WP_Members {
|
|
1168 |
'confirm_password' => __( 'Confirm Password', 'wp-members' ),
|
1169 |
'tos' => __( 'TOS', 'wp-members' ),
|
1170 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1171 |
|
1172 |
$defaults = array(
|
1173 |
|
@@ -1233,6 +1271,7 @@ class WP_Members {
|
|
1233 |
'reg_empty_captcha' => __( 'You must complete the CAPTCHA form.', 'wp-members' ),
|
1234 |
'reg_invalid_captcha' => __( 'CAPTCHA was not valid.', 'wp-members' ),
|
1235 |
'reg_generic' => __( 'There was an error processing the form.', 'wp-members' ),
|
|
|
1236 |
|
1237 |
// Links.
|
1238 |
'profile_edit' => __( 'Edit My Information', 'wp-members' ),
|
@@ -1384,4 +1423,204 @@ class WP_Members {
|
|
1384 |
'std' => '1'
|
1385 |
) );
|
1386 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1387 |
} // End of WP_Members class.
|
321 |
add_action( 'admin_menu', 'wpmem_admin_options' ); // adds admin menu
|
322 |
add_action( 'user_register', 'wpmem_wp_reg_finalize' ); // handles wp native registration
|
323 |
add_action( 'login_enqueue_scripts', 'wpmem_wplogin_stylesheet' ); // styles the native registration
|
324 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) ); // Enqueues the stylesheet.
|
325 |
add_action( 'wp_enqueue_scripts', array( $this, 'loginout_script' ) );
|
326 |
add_action( 'init', array( $this->membership, 'add_cpt' ), 0 ); // Adds membership plans custom post type.
|
327 |
+
add_action( 'wpmem_pwd_change', array( $this->user, 'set_password' ), 9, 2 );
|
328 |
+
add_action( 'wpmem_pwd_change', array( $this->user, 'set_as_logged_in' ), 10 );
|
329 |
add_action( 'pre_get_posts', array( $this, 'do_hide_posts' ) );
|
330 |
add_action( 'customize_register', array( $this, 'customizer_settings' ) );
|
331 |
|
332 |
// Add filters.
|
333 |
add_filter( 'the_content', array( $this, 'do_securify' ), 99 );
|
334 |
+
add_filter( 'allow_password_reset', array( $this->user, 'no_reset' ) ); // no password reset for non-activated users
|
335 |
+
add_filter( 'register_form', 'wpmem_wp_register_form' ); // adds fields to the default wp registration
|
336 |
add_action( 'woocommerce_register_form', 'wpmem_woo_register_form' );
|
337 |
+
add_filter( 'registration_errors', 'wpmem_wp_reg_validate', 10, 3 ); // native registration validation
|
338 |
add_filter( 'comments_open', array( $this, 'do_securify_comments' ), 99 ); // securifies the comments
|
339 |
+
add_filter( 'wpmem_securify', array( $this, 'reg_securify' ) ); // adds success message on login form if redirected
|
340 |
+
add_filter( 'query_vars', array( $this, 'add_query_vars' ), 10, 2 ); // adds custom query vars
|
341 |
add_filter( 'get_pages', array( $this, 'filter_get_pages' ) );
|
342 |
add_filter( 'wp_get_nav_menu_items', array( $this, 'filter_nav_menu_items' ), null, 3 );
|
343 |
+
add_filter( 'get_previous_post_where', array( $this, 'filter_get_adjacent_post_where' ) );
|
344 |
+
add_filter( 'get_next_post_where', array( $this, 'filter_get_adjacent_post_where' ) );
|
345 |
|
346 |
// If registration is moderated, check for activation (blocks backend login by non-activated users).
|
347 |
if ( $this->mod_reg == 1 ) {
|
348 |
+
add_filter( 'authenticate', array( $this->user, 'check_activated' ), 99, 3 );
|
349 |
}
|
350 |
|
351 |
/**
|
410 |
* @since 3.0.0
|
411 |
*/
|
412 |
function load_constants() {
|
413 |
+
( ! defined( 'WPMEM_BLOCK_POSTS' ) ) ? define( 'WPMEM_BLOCK_POSTS', $this->block['post'] ) : ''; // @todo Can deprecate? Probably 3.3
|
414 |
+
( ! defined( 'WPMEM_BLOCK_PAGES' ) ) ? define( 'WPMEM_BLOCK_PAGES', $this->block['page'] ) : ''; // @todo Can deprecate? Probably 3.3
|
415 |
+
( ! defined( 'WPMEM_SHOW_EXCERPT' ) ) ? define( 'WPMEM_SHOW_EXCERPT', $this->show_excerpt['post'] ) : ''; // @todo Can deprecate? Probably 3.3
|
416 |
+
( ! defined( 'WPMEM_NOTIFY_ADMIN' ) ) ? define( 'WPMEM_NOTIFY_ADMIN', $this->notify ) : ''; // @todo Can deprecate? Probably 3.3
|
417 |
+
( ! defined( 'WPMEM_MOD_REG' ) ) ? define( 'WPMEM_MOD_REG', $this->mod_reg ) : ''; // @todo Can deprecate? Probably 3.3
|
418 |
+
( ! defined( 'WPMEM_CAPTCHA' ) ) ? define( 'WPMEM_CAPTCHA', $this->captcha ) : ''; // @todo Can deprecate? Probably 3.3
|
419 |
+
( ! defined( 'WPMEM_NO_REG' ) ) ? define( 'WPMEM_NO_REG', ( -1 * $this->show_reg['post'] ) ) : ''; // @todo Can deprecate? Probably 3.3
|
420 |
( ! defined( 'WPMEM_USE_EXP' ) ) ? define( 'WPMEM_USE_EXP', $this->use_exp ) : '';
|
421 |
( ! defined( 'WPMEM_USE_TRL' ) ) ? define( 'WPMEM_USE_TRL', $this->use_trial ) : '';
|
422 |
+
( ! defined( 'WPMEM_IGNORE_WARN' ) ) ? define( 'WPMEM_IGNORE_WARN', $this->warnings ) : ''; // @todo Can deprecate? Probably 3.3
|
423 |
+
|
424 |
+
( ! defined( 'WPMEM_MSURL' ) ) ? define( 'WPMEM_MSURL', $this->user_pages['profile'] ) : ''; // @todo Can deprecate? Probably 3.3
|
425 |
+
( ! defined( 'WPMEM_REGURL' ) ) ? define( 'WPMEM_REGURL', $this->user_pages['register'] ) : ''; // @todo Can deprecate? Probably 3.3
|
426 |
+
( ! defined( 'WPMEM_LOGURL' ) ) ? define( 'WPMEM_LOGURL', $this->user_pages['login'] ) : ''; // @todo Can deprecate? Probably 3.3
|
427 |
|
|
|
|
|
|
|
|
|
428 |
( ! defined( 'WPMEM_DROPIN_DIR' ) ) ? define( 'WPMEM_DROPIN_DIR', WP_PLUGIN_DIR . '/wp-members-dropins/' ) : '';
|
429 |
|
430 |
define( 'WPMEM_CSSURL', $this->cssurl );
|
460 |
require_once( WPMEM_PATH . 'inc/class-wp-members-widget.php' );
|
461 |
require_once( WPMEM_PATH . 'inc/class-wp-members-products.php' );
|
462 |
require_once( WPMEM_PATH . 'inc/class-wp-members-shortcodes.php' );
|
|
|
463 |
require_once( WPMEM_PATH . 'inc/api.php' );
|
464 |
+
require_once( WPMEM_PATH . 'inc/api-email.php' );
|
465 |
require_once( WPMEM_PATH . 'inc/api-forms.php' );
|
466 |
+
require_once( WPMEM_PATH . 'inc/api-users.php' );
|
467 |
+
require_once( WPMEM_PATH . 'inc/api-utilities.php' );
|
468 |
require_once( WPMEM_PATH . 'inc/forms.php' );
|
469 |
require_once( WPMEM_PATH . 'inc/dialogs.php' );
|
470 |
+
require_once( WPMEM_PATH . 'inc/wp-registration.php' );
|
471 |
+
require_once( WPMEM_PATH . 'inc/deprecated.php' );
|
472 |
+
require_once( WPMEM_PATH . 'inc/core.php' ); // @todo Should be deprecated, functions are obsolete. Schedule for 3.3
|
473 |
+
//require_once( WPMEM_PATH . 'inc/utilities.php' ); // @deprecated 3.2.3
|
474 |
//require_once( WPMEM_PATH . 'inc/sidebar.php' ); // @deprecated 3.2.0
|
475 |
//require_once( WPMEM_PATH . 'inc/shortcodes.php' ); // @deprecated 3.2.0
|
476 |
//require_once( WPMEM_PATH . 'inc/email.php' ); // @deprecated 3.2.0
|
|
|
477 |
//require_once( WPMEM_PATH . 'inc/users.php' ); // @deprecated 3.1.9
|
|
|
478 |
|
479 |
}
|
480 |
|
565 |
|
566 |
case 'pwdchange':
|
567 |
$regchk = $this->user->password_update( 'change' );
|
568 |
+
break;
|
569 |
+
|
570 |
case 'pwdreset':
|
571 |
$regchk = $this->user->password_update( 'reset' );
|
572 |
break;
|
700 |
*
|
701 |
* @since 3.0.0
|
702 |
*
|
|
|
703 |
* @global object $post The WordPress Post object.
|
704 |
+
* @global object $wpmem The WP_Members object.
|
705 |
+
* @global string $wpmem_themsg Contains messages to be output.
|
706 |
* @param string $content
|
707 |
* @return string $content
|
708 |
*/
|
709 |
function do_securify( $content = null ) {
|
710 |
|
711 |
+
global $post, $wpmem, $wpmem_themsg;
|
712 |
|
713 |
$content = ( is_single() || is_page() ) ? $content : wpmem_do_excerpt( $content );
|
714 |
|
716 |
|
717 |
if ( $this->regchk == "captcha" ) {
|
718 |
global $wpmem_captcha_err;
|
719 |
+
$wpmem_themsg = $wpmem->get_text( 'reg_captcha_err' ) . '<br /><br />' . $wpmem_captcha_err;
|
720 |
}
|
721 |
|
722 |
// Block/unblock Posts.
|
806 |
// Fix the wptexturize.
|
807 |
remove_filter( 'the_content', 'wpautop' );
|
808 |
remove_filter( 'the_content', 'wptexturize' );
|
809 |
+
add_filter( 'the_content', array( $this, 'texturize' ), 999 );
|
810 |
}
|
811 |
|
812 |
return $content;
|
893 |
global $wpdb;
|
894 |
$hidden = get_transient( '_wpmem_hidden_posts' );
|
895 |
if ( false === $hidden ) {
|
896 |
+
$hidden = $this->update_hidden_posts();
|
897 |
}
|
898 |
return $hidden;
|
899 |
}
|
904 |
* @since 3.2.0
|
905 |
*
|
906 |
* @global object $wpdb
|
907 |
+
* @return array $hidden
|
908 |
*/
|
909 |
function update_hidden_posts() {
|
910 |
global $wpdb;
|
914 |
$hidden[] = $result->post_id;
|
915 |
}
|
916 |
set_transient( '_wpmem_hidden_posts', $hidden, 60*5 );
|
917 |
+
return $hidden;
|
918 |
}
|
919 |
|
920 |
/**
|
1014 |
return $items;
|
1015 |
}
|
1016 |
|
1017 |
+
/**
|
1018 |
+
* Filter to remove hidden posts from prev/next links.
|
1019 |
+
*
|
1020 |
+
* @since 3.2.4
|
1021 |
+
*
|
1022 |
+
* @global object $wpmem
|
1023 |
+
* @param string $where
|
1024 |
+
* @return string $where
|
1025 |
+
*/
|
1026 |
+
function filter_get_adjacent_post_where( $where ) {
|
1027 |
+
global $wpmem;
|
1028 |
+
$hidden_posts = $this->get_hidden_posts();
|
1029 |
+
if ( ! empty( $hidden_posts ) ) {
|
1030 |
+
$hidden = implode( ",", $hidden_posts );
|
1031 |
+
$where = $where . " AND p.ID NOT IN ( $hidden )";
|
1032 |
+
}
|
1033 |
+
return $where;
|
1034 |
+
}
|
1035 |
+
|
1036 |
/**
|
1037 |
* Sets the registration fields.
|
1038 |
*
|
1196 |
'confirm_password' => __( 'Confirm Password', 'wp-members' ),
|
1197 |
'tos' => __( 'TOS', 'wp-members' ),
|
1198 |
);
|
1199 |
+
|
1200 |
+
/*
|
1201 |
+
* Strings to be added in a future version, included so they will
|
1202 |
+
* be in the translation template ahead of time.
|
1203 |
+
* @todo Remove this once these strings have been officially included.
|
1204 |
+
*/
|
1205 |
+
$benign_strings = array(
|
1206 |
+
__( 'No fields selected for deletion', 'wp-members' ),
|
1207 |
+
__( 'Username or Email', 'wp-members' ),
|
1208 |
+
);
|
1209 |
|
1210 |
$defaults = array(
|
1211 |
|
1271 |
'reg_empty_captcha' => __( 'You must complete the CAPTCHA form.', 'wp-members' ),
|
1272 |
'reg_invalid_captcha' => __( 'CAPTCHA was not valid.', 'wp-members' ),
|
1273 |
'reg_generic' => __( 'There was an error processing the form.', 'wp-members' ),
|
1274 |
+
'reg_captcha_err' => __( 'There was an error with the CAPTCHA form.', 'wp-members' ),
|
1275 |
|
1276 |
// Links.
|
1277 |
'profile_edit' => __( 'Edit My Information', 'wp-members' ),
|
1423 |
'std' => '1'
|
1424 |
) );
|
1425 |
}
|
1426 |
+
|
1427 |
+
/**
|
1428 |
+
* Overrides the wptexturize filter.
|
1429 |
+
*
|
1430 |
+
* Currently only used for the login form to remove the <br> tag that WP puts in after the "Remember Me".
|
1431 |
+
*
|
1432 |
+
* @since 2.6.4
|
1433 |
+
* @since 3.2.3 Moved to WP_Members class.
|
1434 |
+
*
|
1435 |
+
* @todo Possibly deprecate or severely alter this process as its need may be obsolete.
|
1436 |
+
*
|
1437 |
+
* @param string $content
|
1438 |
+
* @return string $new_content
|
1439 |
+
*/
|
1440 |
+
function texturize( $content ) {
|
1441 |
+
|
1442 |
+
$new_content = '';
|
1443 |
+
$pattern_full = '{(\[wpmem_txt\].*?\[/wpmem_txt\])}is';
|
1444 |
+
$pattern_contents = '{\[wpmem_txt\](.*?)\[/wpmem_txt\]}is';
|
1445 |
+
$pieces = preg_split( $pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE );
|
1446 |
+
|
1447 |
+
foreach ( $pieces as $piece ) {
|
1448 |
+
if ( preg_match( $pattern_contents, $piece, $matches ) ) {
|
1449 |
+
$new_content .= $matches[1];
|
1450 |
+
} else {
|
1451 |
+
$new_content .= wptexturize( wpautop( $piece ) );
|
1452 |
+
}
|
1453 |
+
}
|
1454 |
+
|
1455 |
+
return $new_content;
|
1456 |
+
}
|
1457 |
+
|
1458 |
+
/**
|
1459 |
+
* Loads the stylesheet for tableless forms.
|
1460 |
+
*
|
1461 |
+
* @since 2.6
|
1462 |
+
* @since 3.2.3 Moved to WP_Members class.
|
1463 |
+
*
|
1464 |
+
* @global object $wpmem The WP_Members object.
|
1465 |
+
*/
|
1466 |
+
function enqueue_style() {
|
1467 |
+
global $wpmem;
|
1468 |
+
wp_enqueue_style ( 'wp-members', wpmem_force_ssl( $wpmem->cssurl ), '', WPMEM_VERSION );
|
1469 |
+
}
|
1470 |
+
|
1471 |
+
/**
|
1472 |
+
* Creates an excerpt on the fly if there is no 'more' tag.
|
1473 |
+
*
|
1474 |
+
* @since 2.6
|
1475 |
+
* @since 3.2.3 Moved to WP_Members class.
|
1476 |
+
*
|
1477 |
+
* @global object $post The post object.
|
1478 |
+
* @global object $wpmem The WP_Members object.
|
1479 |
+
*
|
1480 |
+
* @param string $content
|
1481 |
+
* @return string $content
|
1482 |
+
*/
|
1483 |
+
function do_excerpt( $content ) {
|
1484 |
+
|
1485 |
+
global $post, $more, $wpmem;
|
1486 |
+
|
1487 |
+
$autoex = ( isset( $wpmem->autoex[ $post->post_type ] ) && 1 == $wpmem->autoex[ $post->post_type ]['enabled'] ) ? $wpmem->autoex[ $post->post_type ] : false;
|
1488 |
+
|
1489 |
+
// Is there already a 'more' link in the content?
|
1490 |
+
$has_more_link = ( stristr( $content, 'class="more-link"' ) ) ? true : false;
|
1491 |
+
|
1492 |
+
// If auto_ex is on.
|
1493 |
+
if ( $autoex ) {
|
1494 |
+
|
1495 |
+
// Build an excerpt if one does not exist.
|
1496 |
+
if ( ! $has_more_link ) {
|
1497 |
+
|
1498 |
+
$is_singular = ( is_singular( $post->post_type ) ) ? true : false;
|
1499 |
+
|
1500 |
+
if ( $is_singular ) {
|
1501 |
+
// If it's a single post, we don't need the 'more' link.
|
1502 |
+
$more_link_text = '';
|
1503 |
+
$more_link = '';
|
1504 |
+
} else {
|
1505 |
+
// The default $more_link_text.
|
1506 |
+
if ( isset( $wpmem->autoex[ $post->post_type ]['text'] ) && '' != $wpmem->autoex[ $post->post_type ]['text'] ) {
|
1507 |
+
$more_link_text = __( $wpmem->autoex[ $post->post_type ]['text'], 'wp-members' );
|
1508 |
+
} else {
|
1509 |
+
$more_link_text = __( '(more…)' );
|
1510 |
+
}
|
1511 |
+
// The default $more_link.
|
1512 |
+
$more_link = ' <a href="'. get_permalink( $post->ID ) . '" class="more-link">' . $more_link_text . '</a>';
|
1513 |
+
}
|
1514 |
+
|
1515 |
+
// Apply the_content_more_link filter if one exists (will match up all 'more' link text).
|
1516 |
+
/** This filter is documented in /wp-includes/post-template.php */
|
1517 |
+
$more_link = apply_filters( 'the_content_more_link', $more_link, $more_link_text );
|
1518 |
+
|
1519 |
+
$defaults = array(
|
1520 |
+
'length' => $autoex['length'],
|
1521 |
+
'more_link' => $more_link,
|
1522 |
+
'blocked_only' => false,
|
1523 |
+
);
|
1524 |
+
/**
|
1525 |
+
* Filter auto excerpt defaults.
|
1526 |
+
*
|
1527 |
+
* @since 3.0.9
|
1528 |
+
* @since 3.1.5 Deprecated add_ellipsis, strip_tags, close_tags, parse_shortcodes, strip_shortcodes.
|
1529 |
+
*
|
1530 |
+
* @param array {
|
1531 |
+
* An array of settings to override the function defaults.
|
1532 |
+
*
|
1533 |
+
* @type int $length The default length of the excerpt.
|
1534 |
+
* @type string $more_link The more link HTML.
|
1535 |
+
* @type boolean $blocked_only Run autoexcerpt only on blocked content. default: false.
|
1536 |
+
* }
|
1537 |
+
* @param string $post->ID The post ID.
|
1538 |
+
* @param string $post->post_type The content's post type.
|
1539 |
+
*/
|
1540 |
+
$args = apply_filters( 'wpmem_auto_excerpt_args', '', $post->ID, $post->post_type );
|
1541 |
+
|
1542 |
+
// Merge settings.
|
1543 |
+
$args = wp_parse_args( $args, $defaults );
|
1544 |
+
|
1545 |
+
// Are we only excerpting blocked content?
|
1546 |
+
if ( $args['blocked_only'] ) {
|
1547 |
+
$post_meta = get_post_meta( $post->ID, '_wpmem_block', true );
|
1548 |
+
if ( 1 == $wpmem->block[ $post->post_type ] ) {
|
1549 |
+
// Post type is blocked, if post meta unblocks it, don't do excerpt.
|
1550 |
+
$do_excerpt = ( "0" == $post_meta ) ? false : true;
|
1551 |
+
} else {
|
1552 |
+
// Post type is unblocked, if post meta blocks it, do excerpt.
|
1553 |
+
$do_excerpt = ( "1" == $post_meta ) ? true : false;
|
1554 |
+
}
|
1555 |
+
} else {
|
1556 |
+
$do_excerpt = true;
|
1557 |
+
}
|
1558 |
+
|
1559 |
+
if ( $do_excerpt ) {
|
1560 |
+
$content = wp_trim_words( $content, $args['length'], $args['more_link'] );
|
1561 |
+
// Check if the more link was added (note: singular has no more_link):
|
1562 |
+
if ( ! $is_singular && ! strpos( $content, $args['more_link'] ) ) {
|
1563 |
+
$content = $content . $args['more_link'];
|
1564 |
+
}
|
1565 |
+
}
|
1566 |
+
|
1567 |
+
}
|
1568 |
+
}
|
1569 |
+
|
1570 |
+
/**
|
1571 |
+
* Filter the auto excerpt.
|
1572 |
+
*
|
1573 |
+
* @since 2.8.1
|
1574 |
+
* @since 3.0.9 Added post ID and post type parameters.
|
1575 |
+
*
|
1576 |
+
* @param string $content The content excerpt.
|
1577 |
+
* @param string $post->ID The post ID.
|
1578 |
+
* @param string $post->post_type The content's post type.
|
1579 |
+
*/
|
1580 |
+
$content = apply_filters( 'wpmem_auto_excerpt', $content, $post->ID, $post->post_type );
|
1581 |
+
|
1582 |
+
// Return the excerpt.
|
1583 |
+
return $content;
|
1584 |
+
}
|
1585 |
+
|
1586 |
+
/**
|
1587 |
+
* Convert form tag.
|
1588 |
+
*
|
1589 |
+
* @todo This is temporary to handle form tag conversion.
|
1590 |
+
*
|
1591 |
+
* @since 3.1.7
|
1592 |
+
* @since 3.2.3 Moved to WP_Members class.
|
1593 |
+
*
|
1594 |
+
* @param string $tag
|
1595 |
+
* @return string $tag
|
1596 |
+
*/
|
1597 |
+
function convert_tag( $tag ) {
|
1598 |
+
switch ( $tag ) {
|
1599 |
+
case 'new':
|
1600 |
+
return 'register';
|
1601 |
+
break;
|
1602 |
+
case 'edit':
|
1603 |
+
case 'update':
|
1604 |
+
return 'profile';
|
1605 |
+
break;
|
1606 |
+
case 'wp':
|
1607 |
+
case 'wp_validate':
|
1608 |
+
case 'wp_finalize':
|
1609 |
+
return 'register_wp';
|
1610 |
+
break;
|
1611 |
+
case 'dashboard_profile':
|
1612 |
+
case 'dashboard_profile_update':
|
1613 |
+
return 'profile_dashboard';
|
1614 |
+
break;
|
1615 |
+
case 'admin_profile':
|
1616 |
+
case 'admin_profile_update':
|
1617 |
+
return 'profile_admin';
|
1618 |
+
break;
|
1619 |
+
default:
|
1620 |
+
return $tag;
|
1621 |
+
break;
|
1622 |
+
}
|
1623 |
+
return $tag;
|
1624 |
+
}
|
1625 |
+
|
1626 |
} // End of WP_Members class.
|
inc/core.php
CHANGED
@@ -60,25 +60,6 @@ function wpmem_securify( $content = null ) {
|
|
60 |
endif;
|
61 |
|
62 |
|
63 |
-
if ( ! function_exists( 'wpmem_check_activated' ) ):
|
64 |
-
/**
|
65 |
-
* Checks if a user is activated.
|
66 |
-
*
|
67 |
-
* @since 2.7.1
|
68 |
-
*
|
69 |
-
* @param object $user The WordPress User object.
|
70 |
-
* @param string $username The user's username (user_login).
|
71 |
-
* @param string $password The user's password.
|
72 |
-
* @return object $user The WordPress User object.
|
73 |
-
*/
|
74 |
-
function wpmem_check_activated( $user, $username, $password ) {
|
75 |
-
global $wpmem;
|
76 |
-
$user = $wpmem->user->check_activated( $user, $username, $password );
|
77 |
-
return $user;
|
78 |
-
}
|
79 |
-
endif;
|
80 |
-
|
81 |
-
|
82 |
if ( ! function_exists( 'wpmem_login' ) ):
|
83 |
/**
|
84 |
* Logs in the user.
|
@@ -156,22 +137,6 @@ function wpmem_reset_password() {
|
|
156 |
}
|
157 |
endif;
|
158 |
|
159 |
-
|
160 |
-
if ( ! function_exists( 'wpmem_no_reset' ) ):
|
161 |
-
/**
|
162 |
-
* Prevents users not activated from resetting their password.
|
163 |
-
*
|
164 |
-
* @since 2.5.1
|
165 |
-
* @since 3.2.0 Now a wrapper for $wpmem->user->no_reset().
|
166 |
-
*
|
167 |
-
* @return bool Returns false if the user is not activated, otherwise true.
|
168 |
-
*/
|
169 |
-
function wpmem_no_reset() {
|
170 |
-
global $wpmem;
|
171 |
-
return $wpmem->user->no_reset();
|
172 |
-
}
|
173 |
-
endif;
|
174 |
-
|
175 |
/**
|
176 |
* Handles retrieving a forgotten username.
|
177 |
*
|
60 |
endif;
|
61 |
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
if ( ! function_exists( 'wpmem_login' ) ):
|
64 |
/**
|
65 |
* Logs in the user.
|
137 |
}
|
138 |
endif;
|
139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
/**
|
141 |
* Handles retrieving a forgotten username.
|
142 |
*
|
inc/deprecated.php
CHANGED
@@ -767,30 +767,6 @@ function wpmem_profile_update() {
|
|
767 |
}
|
768 |
}
|
769 |
|
770 |
-
/**
|
771 |
-
* Sets user profile update to multipart form data.
|
772 |
-
*
|
773 |
-
* If the fields array has a file or image field, this will echo the
|
774 |
-
* necessary "multipart/form-data" enctype for the form tag.
|
775 |
-
*
|
776 |
-
* @since 3.1.8
|
777 |
-
* @deprecated 3.1.9
|
778 |
-
*/
|
779 |
-
function wpmem_user_profile_multipart() {
|
780 |
-
|
781 |
-
wpmem_write_log( "wpmem_user_profile_multipart() is deprecated. No alternative function exists." );
|
782 |
-
|
783 |
-
global $wpmem;
|
784 |
-
$has_file = false;
|
785 |
-
foreach ( wpmem_fields() as $field ) {
|
786 |
-
if ( $field['type'] == 'file' || $field['type'] == 'image' ) {
|
787 |
-
$has_file = true;
|
788 |
-
break;
|
789 |
-
}
|
790 |
-
}
|
791 |
-
echo ( $has_file ) ? " enctype=\"multipart/form-data\"" : '';
|
792 |
-
}
|
793 |
-
|
794 |
if ( ! function_exists( 'wpmem_inc_status' ) ):
|
795 |
/**
|
796 |
* Generate users login status if logged in and gives logout link.
|
@@ -1092,7 +1068,7 @@ function wpmem_sc_fields( $atts, $content = null, $tag ) {
|
|
1092 |
* Logout link shortcode [wpmem_logout].
|
1093 |
*
|
1094 |
* @since 3.1.2
|
1095 |
-
* @
|
1096 |
*
|
1097 |
* @global object $wpmem The WP_Members object.
|
1098 |
* @param array $atts {
|
@@ -1113,7 +1089,7 @@ function wpmem_sc_logout( $atts, $content, $tag ) {
|
|
1113 |
* TOS shortcode [wpmem_tos].
|
1114 |
*
|
1115 |
* @since 3.1.2
|
1116 |
-
* @
|
1117 |
*
|
1118 |
* @global object $wpmem The WP_Members object.
|
1119 |
* @param array $atts {
|
@@ -1134,7 +1110,7 @@ function wpmem_sc_tos( $atts, $content, $tag ) {
|
|
1134 |
* Display user avatar.
|
1135 |
*
|
1136 |
* @since 3.1.7
|
1137 |
-
* @
|
1138 |
*
|
1139 |
* @global object $wpmem The WP_Members object.
|
1140 |
* @param array $atts {
|
@@ -1156,7 +1132,7 @@ function wpmem_sc_avatar( $atts, $content, $tag ) {
|
|
1156 |
* Generates a login link with a return url.
|
1157 |
*
|
1158 |
* @since 3.1.7
|
1159 |
-
* @
|
1160 |
*
|
1161 |
* @global object $wpmem The WP_Members object.
|
1162 |
* @param array $atts {
|
@@ -1180,7 +1156,7 @@ if ( ! function_exists( 'wpmem_inc_regemail' ) ):
|
|
1180 |
* @since 2.9.7 Major overhaul, added wpmem_email_filter filter.
|
1181 |
* @since 3.1.0 Can filter in custom shortcodes with wpmem_email_shortcodes.
|
1182 |
* @since 3.1.1 Added $custom argument for custom emails.
|
1183 |
-
* @
|
1184 |
*
|
1185 |
* @global object $wpmem The WP_Members object.
|
1186 |
* @global string $wpmem_mail_from The email from address.
|
@@ -1199,55 +1175,22 @@ function wpmem_inc_regemail( $user_id, $password, $toggle, $wpmem_fields = null,
|
|
1199 |
}
|
1200 |
endif;
|
1201 |
|
1202 |
-
|
1203 |
-
if ( ! function_exists( 'wpmem_notify_admin' ) ):
|
1204 |
/**
|
1205 |
-
*
|
1206 |
-
*
|
1207 |
-
* @since 2.
|
1208 |
-
* @
|
1209 |
-
*
|
1210 |
-
* @
|
1211 |
-
* @param
|
1212 |
-
* @param
|
1213 |
-
* @
|
1214 |
-
*/
|
1215 |
-
function
|
|
|
1216 |
global $wpmem;
|
1217 |
-
$wpmem->
|
|
|
1218 |
}
|
1219 |
endif;
|
1220 |
-
|
1221 |
-
|
1222 |
-
/**
|
1223 |
-
* Filters the wp_mail from address (if set).
|
1224 |
-
*
|
1225 |
-
* @since 2.7.0
|
1226 |
-
* @since 3.1.0 Converted to use email var in object.
|
1227 |
-
* @since 3.2.0 Now a wrapper for WP_Members_Email::from().
|
1228 |
-
*
|
1229 |
-
* @global object $wpmem
|
1230 |
-
* @param string $email
|
1231 |
-
* @return string $wpmem_mail_from|$email
|
1232 |
-
*/
|
1233 |
-
function wpmem_mail_from( $email ) {
|
1234 |
-
global $wpmem;
|
1235 |
-
return $wpmem->email->from( $email );
|
1236 |
-
}
|
1237 |
-
|
1238 |
-
|
1239 |
-
/**
|
1240 |
-
* Filters the wp_mail from name (if set).
|
1241 |
-
*
|
1242 |
-
* @since 2.7.0
|
1243 |
-
* @since 3.1.0 Converted to use email var in object.
|
1244 |
-
* @since 3.2.0 Now a wrapper for WP_Members_Email::from_name().
|
1245 |
-
*
|
1246 |
-
* @global object $wpmem
|
1247 |
-
* @param string $name
|
1248 |
-
* @return string $wpmem_mail_from_name|$name
|
1249 |
-
*/
|
1250 |
-
function wpmem_mail_from_name( $name ) {
|
1251 |
-
global $wpmem;
|
1252 |
-
return $wpmem->email->from_name( $name );
|
1253 |
-
}
|
767 |
}
|
768 |
}
|
769 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
770 |
if ( ! function_exists( 'wpmem_inc_status' ) ):
|
771 |
/**
|
772 |
* Generate users login status if logged in and gives logout link.
|
1068 |
* Logout link shortcode [wpmem_logout].
|
1069 |
*
|
1070 |
* @since 3.1.2
|
1071 |
+
* @deprecated 3.2.0 Use WP_Members_Shortcodes::logout() instead.
|
1072 |
*
|
1073 |
* @global object $wpmem The WP_Members object.
|
1074 |
* @param array $atts {
|
1089 |
* TOS shortcode [wpmem_tos].
|
1090 |
*
|
1091 |
* @since 3.1.2
|
1092 |
+
* @deprecated 3.2.0 Use WP_Members_Shortcodes::tos() instead.
|
1093 |
*
|
1094 |
* @global object $wpmem The WP_Members object.
|
1095 |
* @param array $atts {
|
1110 |
* Display user avatar.
|
1111 |
*
|
1112 |
* @since 3.1.7
|
1113 |
+
* @deprecated 3.2.0 Use WP_Members_Shortcodes::avatar() instead.
|
1114 |
*
|
1115 |
* @global object $wpmem The WP_Members object.
|
1116 |
* @param array $atts {
|
1132 |
* Generates a login link with a return url.
|
1133 |
*
|
1134 |
* @since 3.1.7
|
1135 |
+
* @deprecated 3.2.0 Use WP_Members_Shortcodes::login_link() instead.
|
1136 |
*
|
1137 |
* @global object $wpmem The WP_Members object.
|
1138 |
* @param array $atts {
|
1156 |
* @since 2.9.7 Major overhaul, added wpmem_email_filter filter.
|
1157 |
* @since 3.1.0 Can filter in custom shortcodes with wpmem_email_shortcodes.
|
1158 |
* @since 3.1.1 Added $custom argument for custom emails.
|
1159 |
+
* @deprecated 3.2.0 Use WP_Members_Email::to_user() instead.
|
1160 |
*
|
1161 |
* @global object $wpmem The WP_Members object.
|
1162 |
* @global string $wpmem_mail_from The email from address.
|
1175 |
}
|
1176 |
endif;
|
1177 |
|
1178 |
+
if ( ! function_exists( 'wpmem_check_activated' ) ):
|
|
|
1179 |
/**
|
1180 |
+
* Checks if a user is activated.
|
1181 |
+
*
|
1182 |
+
* @since 2.7.1
|
1183 |
+
* @deprecated 3.2.2 Use wpmem_is_user_activated() instead.
|
1184 |
+
*
|
1185 |
+
* @param object $user The WordPress User object.
|
1186 |
+
* @param string $username The user's username (user_login).
|
1187 |
+
* @param string $password The user's password.
|
1188 |
+
* @return object $user The WordPress User object.
|
1189 |
+
*/
|
1190 |
+
function wpmem_check_activated( $user, $username, $password ) {
|
1191 |
+
wpmem_write_log( "wpmem_check_activated() is deprecated since WP-Members 3.2.2. Use wpmem_is_user_activated() instead" );
|
1192 |
global $wpmem;
|
1193 |
+
$user = $wpmem->user->check_activated( $user, $username, $password );
|
1194 |
+
return $user;
|
1195 |
}
|
1196 |
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/dialogs.php
CHANGED
@@ -21,7 +21,6 @@
|
|
21 |
* - wpmem_page_user_edit
|
22 |
* - wpmem_page_forgot_username
|
23 |
* - wpmem_inc_forgotusername
|
24 |
-
* - wpmem_inc_status
|
25 |
*/
|
26 |
|
27 |
// Exit if accessed directly.
|
@@ -62,6 +61,8 @@ function wpmem_inc_loginfailed() {
|
|
62 |
*
|
63 |
* @since 2.9.0
|
64 |
*
|
|
|
|
|
65 |
* @param array An array of arguments to merge with defaults.
|
66 |
*/
|
67 |
$args = apply_filters( 'wpmem_login_failed_args', '' );
|
@@ -80,6 +81,8 @@ function wpmem_inc_loginfailed() {
|
|
80 |
*
|
81 |
* @since 2.7.3
|
82 |
*
|
|
|
|
|
83 |
* @param string $str The login failed dialog.
|
84 |
*/
|
85 |
$str = apply_filters( 'wpmem_login_failed', $str );
|
21 |
* - wpmem_page_user_edit
|
22 |
* - wpmem_page_forgot_username
|
23 |
* - wpmem_inc_forgotusername
|
|
|
24 |
*/
|
25 |
|
26 |
// Exit if accessed directly.
|
61 |
*
|
62 |
* @since 2.9.0
|
63 |
*
|
64 |
+
* @todo Needs probably to pass user ID or some identifier so we can get user info without going to the post object and then get_user_by().
|
65 |
+
*
|
66 |
* @param array An array of arguments to merge with defaults.
|
67 |
*/
|
68 |
$args = apply_filters( 'wpmem_login_failed_args', '' );
|
81 |
*
|
82 |
* @since 2.7.3
|
83 |
*
|
84 |
+
* @todo Needs probably to pass user ID or some identifier so we can get user info without going to the post object and then get_user_by().
|
85 |
+
*
|
86 |
* @param string $str The login failed dialog.
|
87 |
*/
|
88 |
$str = apply_filters( 'wpmem_login_failed', $str );
|
inc/utilities.php
DELETED
@@ -1,351 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WP-Members Utility Functions
|
4 |
-
*
|
5 |
-
* Handles primary functions that are carried out in most
|
6 |
-
* situations. Includes commonly used utility functions.
|
7 |
-
*
|
8 |
-
* This file is part of the WP-Members plugin by Chad Butler
|
9 |
-
* You can find out more about this plugin at https://rocketgeek.com
|
10 |
-
* Copyright (c) 2006-2018 Chad Butler
|
11 |
-
* WP-Members(tm) is a trademark of butlerblog.com
|
12 |
-
*
|
13 |
-
* @package WP-Members
|
14 |
-
* @subpackage WP-Members Utility Functions
|
15 |
-
* @author Chad Butler
|
16 |
-
* @copyright 2006-2018
|
17 |
-
*
|
18 |
-
* Functions included:
|
19 |
-
* - wpmem_create_formfield
|
20 |
-
* - wpmem_texturize
|
21 |
-
* - wpmem_enqueue_style
|
22 |
-
* - wpmem_do_excerpt
|
23 |
-
* - wpmem_get_excluded_meta
|
24 |
-
* - wpmem_use_ssl
|
25 |
-
* - wpmem_wp_reserved_terms
|
26 |
-
* - wpmem_write_log
|
27 |
-
*/
|
28 |
-
|
29 |
-
// Exit if accessed directly.
|
30 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
31 |
-
exit();
|
32 |
-
}
|
33 |
-
|
34 |
-
|
35 |
-
if ( ! function_exists( 'wpmem_texturize' ) ):
|
36 |
-
/**
|
37 |
-
* Overrides the wptexturize filter.
|
38 |
-
*
|
39 |
-
* Currently only used for the login form to remove the <br> tag that WP puts in after the "Remember Me".
|
40 |
-
*
|
41 |
-
* @since 2.6.4
|
42 |
-
*
|
43 |
-
* @todo Possibly deprecate or severely alter this process as its need may be obsolete.
|
44 |
-
*
|
45 |
-
* @param string $content
|
46 |
-
* @return string $new_content
|
47 |
-
*/
|
48 |
-
function wpmem_texturize( $content ) {
|
49 |
-
|
50 |
-
$new_content = '';
|
51 |
-
$pattern_full = '{(\[wpmem_txt\].*?\[/wpmem_txt\])}is';
|
52 |
-
$pattern_contents = '{\[wpmem_txt\](.*?)\[/wpmem_txt\]}is';
|
53 |
-
$pieces = preg_split( $pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE );
|
54 |
-
|
55 |
-
foreach ( $pieces as $piece ) {
|
56 |
-
if ( preg_match( $pattern_contents, $piece, $matches ) ) {
|
57 |
-
$new_content .= $matches[1];
|
58 |
-
} else {
|
59 |
-
$new_content .= wptexturize( wpautop( $piece ) );
|
60 |
-
}
|
61 |
-
}
|
62 |
-
|
63 |
-
return $new_content;
|
64 |
-
}
|
65 |
-
endif;
|
66 |
-
|
67 |
-
|
68 |
-
if ( ! function_exists( 'wpmem_enqueue_style' ) ):
|
69 |
-
/**
|
70 |
-
* Loads the stylesheet for tableless forms.
|
71 |
-
*
|
72 |
-
* @since 2.6
|
73 |
-
*
|
74 |
-
* @global object $wpmem The WP_Members object.
|
75 |
-
*/
|
76 |
-
function wpmem_enqueue_style() {
|
77 |
-
global $wpmem;
|
78 |
-
wp_enqueue_style ( 'wp-members', $wpmem->cssurl, '', WPMEM_VERSION );
|
79 |
-
}
|
80 |
-
endif;
|
81 |
-
|
82 |
-
|
83 |
-
if ( ! function_exists( 'wpmem_do_excerpt' ) ):
|
84 |
-
/**
|
85 |
-
* Creates an excerpt on the fly if there is no 'more' tag.
|
86 |
-
*
|
87 |
-
* @since 2.6
|
88 |
-
*
|
89 |
-
* @global object $post The post object.
|
90 |
-
* @global object $wpmem The WP_Members object.
|
91 |
-
*
|
92 |
-
* @param string $content
|
93 |
-
* @return string $content
|
94 |
-
*/
|
95 |
-
function wpmem_do_excerpt( $content ) {
|
96 |
-
|
97 |
-
global $post, $more, $wpmem;
|
98 |
-
|
99 |
-
$autoex = ( isset( $wpmem->autoex[ $post->post_type ] ) && 1 == $wpmem->autoex[ $post->post_type ]['enabled'] ) ? $wpmem->autoex[ $post->post_type ] : false;
|
100 |
-
|
101 |
-
// Is there already a 'more' link in the content?
|
102 |
-
$has_more_link = ( stristr( $content, 'class="more-link"' ) ) ? true : false;
|
103 |
-
|
104 |
-
// If auto_ex is on.
|
105 |
-
if ( $autoex ) {
|
106 |
-
|
107 |
-
// Build an excerpt if one does not exist.
|
108 |
-
if ( ! $has_more_link ) {
|
109 |
-
|
110 |
-
$is_singular = ( is_singular( $post->post_type ) ) ? true : false;
|
111 |
-
|
112 |
-
if ( $is_singular ) {
|
113 |
-
// If it's a single post, we don't need the 'more' link.
|
114 |
-
$more_link_text = '';
|
115 |
-
$more_link = '';
|
116 |
-
} else {
|
117 |
-
// The default $more_link_text.
|
118 |
-
if ( isset( $wpmem->autoex[ $post->post_type ]['text'] ) && '' != $wpmem->autoex[ $post->post_type ]['text'] ) {
|
119 |
-
$more_link_text = __( $wpmem->autoex[ $post->post_type ]['text'], 'wp-members' );
|
120 |
-
} else {
|
121 |
-
$more_link_text = __( '(more…)' );
|
122 |
-
}
|
123 |
-
// The default $more_link.
|
124 |
-
$more_link = ' <a href="'. get_permalink( $post->ID ) . '" class="more-link">' . $more_link_text . '</a>';
|
125 |
-
}
|
126 |
-
|
127 |
-
// Apply the_content_more_link filter if one exists (will match up all 'more' link text).
|
128 |
-
/** This filter is documented in /wp-includes/post-template.php */
|
129 |
-
$more_link = apply_filters( 'the_content_more_link', $more_link, $more_link_text );
|
130 |
-
|
131 |
-
$defaults = array(
|
132 |
-
'length' => $autoex['length'],
|
133 |
-
'more_link' => $more_link,
|
134 |
-
'blocked_only' => false,
|
135 |
-
);
|
136 |
-
/**
|
137 |
-
* Filter auto excerpt defaults.
|
138 |
-
*
|
139 |
-
* @since 3.0.9
|
140 |
-
* @since 3.1.5 Deprecated add_ellipsis, strip_tags, close_tags, parse_shortcodes, strip_shortcodes.
|
141 |
-
*
|
142 |
-
* @param array {
|
143 |
-
* An array of settings to override the function defaults.
|
144 |
-
*
|
145 |
-
* @type int $length The default length of the excerpt.
|
146 |
-
* @type string $more_link The more link HTML.
|
147 |
-
* @type boolean $blocked_only Run autoexcerpt only on blocked content. default: false.
|
148 |
-
* }
|
149 |
-
* @param string $post->ID The post ID.
|
150 |
-
* @param string $post->post_type The content's post type.
|
151 |
-
*/
|
152 |
-
$args = apply_filters( 'wpmem_auto_excerpt_args', '', $post->ID, $post->post_type );
|
153 |
-
|
154 |
-
// Merge settings.
|
155 |
-
$args = wp_parse_args( $args, $defaults );
|
156 |
-
|
157 |
-
// Are we only excerpting blocked content?
|
158 |
-
if ( $args['blocked_only'] ) {
|
159 |
-
$post_meta = get_post_meta( $post->ID, '_wpmem_block', true );
|
160 |
-
if ( 1 == $wpmem->block[ $post->post_type ] ) {
|
161 |
-
// Post type is blocked, if post meta unblocks it, don't do excerpt.
|
162 |
-
$do_excerpt = ( "0" == $post_meta ) ? false : true;
|
163 |
-
} else {
|
164 |
-
// Post type is unblocked, if post meta blocks it, do excerpt.
|
165 |
-
$do_excerpt = ( "1" == $post_meta ) ? true : false;
|
166 |
-
}
|
167 |
-
} else {
|
168 |
-
$do_excerpt = true;
|
169 |
-
}
|
170 |
-
|
171 |
-
if ( $do_excerpt ) {
|
172 |
-
$content = wp_trim_words( $content, $args['length'], $args['more_link'] );
|
173 |
-
// Check if the more link was added (note: singular has no more_link):
|
174 |
-
if ( ! $is_singular && ! strpos( $content, $args['more_link'] ) ) {
|
175 |
-
$content = $content . $args['more_link'];
|
176 |
-
}
|
177 |
-
}
|
178 |
-
|
179 |
-
}
|
180 |
-
}
|
181 |
-
|
182 |
-
/**
|
183 |
-
* Filter the auto excerpt.
|
184 |
-
*
|
185 |
-
* @since 2.8.1
|
186 |
-
* @since 3.0.9 Added post ID and post type parameters.
|
187 |
-
*
|
188 |
-
* @param string $content The content excerpt.
|
189 |
-
* @param string $post->ID The post ID.
|
190 |
-
* @param string $post->post_type The content's post type.
|
191 |
-
*/
|
192 |
-
$content = apply_filters( 'wpmem_auto_excerpt', $content, $post->ID, $post->post_type );
|
193 |
-
|
194 |
-
// Return the excerpt.
|
195 |
-
return $content;
|
196 |
-
}
|
197 |
-
endif;
|
198 |
-
|
199 |
-
|
200 |
-
/**
|
201 |
-
* Sets an array of user meta fields to be excluded from update/insert.
|
202 |
-
*
|
203 |
-
* @since 2.9.3
|
204 |
-
* @since Unknown Now a wrapper for get_excluded_fields().
|
205 |
-
*
|
206 |
-
* @param string $tag A tag so we know where the function is being used.
|
207 |
-
* @return array Array of fields to be excluded from the registration form.
|
208 |
-
*/
|
209 |
-
function wpmem_get_excluded_meta( $tag ) {
|
210 |
-
global $wpmem;
|
211 |
-
return $wpmem->excluded_fields( $tag );
|
212 |
-
}
|
213 |
-
|
214 |
-
|
215 |
-
/**
|
216 |
-
* Returns http:// or https:// depending on ssl.
|
217 |
-
*
|
218 |
-
* @since 2.9.8
|
219 |
-
*
|
220 |
-
* @return string https://|http:// depending on whether ssl is being used.
|
221 |
-
*/
|
222 |
-
function wpmem_use_ssl() {
|
223 |
-
return ( is_ssl() ) ? 'https://' : 'http://';
|
224 |
-
}
|
225 |
-
|
226 |
-
|
227 |
-
/**
|
228 |
-
* Returns an array of WordPress reserved terms.
|
229 |
-
*
|
230 |
-
* @since 3.0.2
|
231 |
-
*
|
232 |
-
* @return array An array of WordPress reserved terms.
|
233 |
-
*/
|
234 |
-
function wpmem_wp_reserved_terms() {
|
235 |
-
$reserved_terms = array( 'attachment', 'attachment_id', 'author', 'author_name', 'calendar', 'cat', 'category', 'category__and', 'category__in', 'category__not_in', 'category_name', 'comments_per_page', 'comments_popup', 'customize_messenger_channel', 'customized', 'cpage', 'day', 'debug', 'error', 'exact', 'feed', 'fields', 'hour', 'link_category', 'm', 'minute', 'monthnum', 'more', 'name', 'nav_menu', 'nonce', 'nopaging', 'offset', 'order', 'orderby', 'p', 'page', 'page_id', 'paged', 'pagename', 'pb', 'perm', 'post', 'post__in', 'post__not_in', 'post_format', 'post_mime_type', 'post_status', 'post_tag', 'post_type', 'posts', 'posts_per_archive_page', 'posts_per_page', 'preview', 'robots', 'role', 's', 'search', 'second', 'sentence', 'showposts', 'static', 'subpost', 'subpost_id', 'tag', 'tag__and', 'tag__in', 'tag__not_in', 'tag_id', 'tag_slug__and', 'tag_slug__in', 'taxonomy', 'tb', 'term', 'theme', 'type', 'w', 'withcomments', 'withoutcomments', 'year' );
|
236 |
-
|
237 |
-
/**
|
238 |
-
* Filter the array of reserved terms.
|
239 |
-
*
|
240 |
-
* @since 3.0.2
|
241 |
-
*
|
242 |
-
* @param array $reserved_terms
|
243 |
-
*/
|
244 |
-
$reserved_terms = apply_filters( 'wpmem_wp_reserved_terms', $reserved_terms );
|
245 |
-
|
246 |
-
return $reserved_terms;
|
247 |
-
}
|
248 |
-
|
249 |
-
|
250 |
-
/**
|
251 |
-
* Log debugging errors.
|
252 |
-
*
|
253 |
-
* @since 3.1.2
|
254 |
-
*
|
255 |
-
* @param mixed (string|array|object) $log Information to write in the WP debug file.
|
256 |
-
*/
|
257 |
-
function wpmem_write_log ( $log ) {
|
258 |
-
if ( is_array( $log ) || is_object( $log ) ) {
|
259 |
-
error_log( print_r( $log, true ) );
|
260 |
-
} else {
|
261 |
-
error_log( $log );
|
262 |
-
}
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Convert form tag.
|
267 |
-
*
|
268 |
-
* @todo This is temporary to handle form tag conversion.
|
269 |
-
*
|
270 |
-
* @since 3.1.7
|
271 |
-
*
|
272 |
-
* @param string $tag
|
273 |
-
* @return string $tag
|
274 |
-
*/
|
275 |
-
function wpmem_convert_tag( $tag ) {
|
276 |
-
switch ( $tag ) {
|
277 |
-
case 'new':
|
278 |
-
return 'register';
|
279 |
-
break;
|
280 |
-
case 'edit':
|
281 |
-
case 'update':
|
282 |
-
return 'profile';
|
283 |
-
break;
|
284 |
-
case 'wp':
|
285 |
-
case 'wp_validate':
|
286 |
-
case 'wp_finalize':
|
287 |
-
return 'register_wp';
|
288 |
-
break;
|
289 |
-
case 'dashboard_profile':
|
290 |
-
case 'dashboard_profile_update':
|
291 |
-
return 'profile_dashboard';
|
292 |
-
break;
|
293 |
-
case 'admin_profile':
|
294 |
-
case 'admin_profile_update':
|
295 |
-
return 'profile_admin';
|
296 |
-
break;
|
297 |
-
default:
|
298 |
-
return $tag;
|
299 |
-
break;
|
300 |
-
}
|
301 |
-
return $tag;
|
302 |
-
}
|
303 |
-
|
304 |
-
/**
|
305 |
-
* String manipulation utility.
|
306 |
-
*
|
307 |
-
* Manipulates a given string based on the location of another string to return
|
308 |
-
* a requested part or parts of the original string. For extracting a string
|
309 |
-
* to get what is before or after, the returned result is a string. If the
|
310 |
-
* string is requested to be "split" by the needle string, an array containing
|
311 |
-
* the parts before, after, and the "needle" are returned.
|
312 |
-
*
|
313 |
-
* @since 3.2.0
|
314 |
-
*
|
315 |
-
* @param string $needle
|
316 |
-
* @param string $haystack
|
317 |
-
* @param string $position (before|after|split default: 'after')
|
318 |
-
* @param boolean $keep_needle (default:true)
|
319 |
-
* @return string|array $new {
|
320 |
-
* An array of the original string, as split by the "needle" string.
|
321 |
-
*
|
322 |
-
* @type string $before
|
323 |
-
* @type string $after
|
324 |
-
* @type string $needle
|
325 |
-
* }
|
326 |
-
*/
|
327 |
-
function wpmem_get_sub_str( $needle, $haystack, $position = 'after', $keep_needle = true ) {
|
328 |
-
$pos = strpos( $haystack, $needle );
|
329 |
-
if ( false === $pos ) {
|
330 |
-
return $haystack;
|
331 |
-
} else {
|
332 |
-
if ( 'before' == $position ) {
|
333 |
-
$new = ( substr( $haystack, 0, $pos ) );
|
334 |
-
$new = ( $keep_needle ) ? $string . $needle : $new;
|
335 |
-
} elseif ( 'after' == $position ) {
|
336 |
-
$new = ( substr( $haystack, $pos+strlen( $needle ) ) );
|
337 |
-
$new = ( $keep_needle ) ? $needle . $string : $new;
|
338 |
-
} elseif ( 'split' == $position ) {
|
339 |
-
$before = ( substr( $haystack, 0, $pos ) );
|
340 |
-
$after = ( substr( $haystack, $pos+strlen( $needle ) ) );
|
341 |
-
$new = array(
|
342 |
-
'before' => $before,
|
343 |
-
'after' => $after,
|
344 |
-
'needle' => $needle,
|
345 |
-
);
|
346 |
-
}
|
347 |
-
}
|
348 |
-
return $new;
|
349 |
-
}
|
350 |
-
|
351 |
-
// End of file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/wp-registration.php
CHANGED
@@ -222,7 +222,7 @@ function wpmem_do_wp_newuser_form() {
|
|
222 |
echo '<table class="form-table"><tbody>';
|
223 |
|
224 |
$wpmem_fields = wpmem_fields( 'add_new' );
|
225 |
-
$exclude = wpmem_get_excluded_meta( 'register' );
|
226 |
|
227 |
foreach ( $wpmem_fields as $meta_key => $field ) {
|
228 |
|
@@ -377,7 +377,7 @@ function wpmem_wp_reg_finalize( $user_id ) {
|
|
377 |
$exclude = wpmem_get_excluded_meta( 'wp-register' );
|
378 |
foreach ( wpmem_fields( 'wp_finalize' ) as $meta_key => $field ) {
|
379 |
$value = wpmem_get( $meta_key, false );
|
380 |
-
if ( $value && ! in_array( $meta_key, $exclude ) && 'file' != $field['type'] && 'image' != $field['type'] ) {
|
381 |
if ( 'multiselect' == $field['type'] || 'multicheckbox' == $field['type'] ) {
|
382 |
$value = implode( $field['delimiter'], $value );
|
383 |
}
|
222 |
echo '<table class="form-table"><tbody>';
|
223 |
|
224 |
$wpmem_fields = wpmem_fields( 'add_new' );
|
225 |
+
$exclude = wpmem_get_excluded_meta( 'wp-register' );
|
226 |
|
227 |
foreach ( $wpmem_fields as $meta_key => $field ) {
|
228 |
|
377 |
$exclude = wpmem_get_excluded_meta( 'wp-register' );
|
378 |
foreach ( wpmem_fields( 'wp_finalize' ) as $meta_key => $field ) {
|
379 |
$value = wpmem_get( $meta_key, false );
|
380 |
+
if ( false !== $value && ! in_array( $meta_key, $exclude ) && 'file' != $field['type'] && 'image' != $field['type'] ) {
|
381 |
if ( 'multiselect' == $field['type'] || 'multicheckbox' == $field['type'] ) {
|
382 |
$value = implode( $field['delimiter'], $value );
|
383 |
}
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: cbutlerjr
|
|
3 |
Tags: access, authentication, content, login, member, membership, password, protect, register, registration, restriction, subscriber
|
4 |
Requires at least: 4.0
|
5 |
Tested up to: 4.9
|
6 |
-
Stable tag: 3.2.2
|
7 |
License: GPLv2
|
8 |
|
9 |
The WP-Members membership plugin turns your WordPress site into a membership site. Restrict premium content, create custom registration fields, and more.
|
@@ -104,7 +104,7 @@ Premium priority support is available at the plugin's site [RocketGeek.com](http
|
|
104 |
== Upgrade Notice ==
|
105 |
|
106 |
WP-Members 3.2.0 is a major update. See changelog for important details. Minimum WP version is 4.0.
|
107 |
-
WP-Members 3.2.2
|
108 |
|
109 |
== Screenshots ==
|
110 |
|
@@ -127,13 +127,38 @@ WP-Members 3.2.2.1 is a bug fix update. See changelog.
|
|
127 |
|
128 |
== Changelog ==
|
129 |
|
130 |
-
= 3.2.2
|
131 |
|
132 |
-
*
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
= 3.2.2 =
|
136 |
|
|
|
137 |
* Fixed a 3.2 upgrade issue, verifies username field is properly added to field settings array.
|
138 |
* Fixed issue with user product verification where only expiration products were validated.
|
139 |
* Fixed logic in form field builder so multiselect will accept a custom class.
|
3 |
Tags: access, authentication, content, login, member, membership, password, protect, register, registration, restriction, subscriber
|
4 |
Requires at least: 4.0
|
5 |
Tested up to: 4.9
|
6 |
+
Stable tag: 3.2.3.2
|
7 |
License: GPLv2
|
8 |
|
9 |
The WP-Members membership plugin turns your WordPress site into a membership site. Restrict premium content, create custom registration fields, and more.
|
104 |
== Upgrade Notice ==
|
105 |
|
106 |
WP-Members 3.2.0 is a major update. See changelog for important details. Minimum WP version is 4.0.
|
107 |
+
WP-Members 3.2.3.2 is a minor update for 3.2.3. See changelog.
|
108 |
|
109 |
== Screenshots ==
|
110 |
|
127 |
|
128 |
== Changelog ==
|
129 |
|
130 |
+
= 3.2.3.2 =
|
131 |
|
132 |
+
* Bug fix where export functions are not loaded correctly when exporting individual users.
|
133 |
+
|
134 |
+
= 3.2.3.1 =
|
135 |
+
|
136 |
+
* Login with username or email address was added in 3.2.3. HOWEVER, this was intended to be a "soft launch" and the login form label "Username" was not intended to be changed. This update changes the label back to "Username" until translations can catch up and other testing has been completed. The functionality remains for login with username or email, so feel free to filter the label.
|
137 |
+
* Implemented change in the native WP registration form processing to allow values of "0" to be interpreted as string literals. Previously could be interpreted as boolean when being saved.
|
138 |
+
|
139 |
+
= 3.2.3 =
|
140 |
+
|
141 |
+
* Bug fix in user export that caused usernames to be dropped.
|
142 |
+
* Bug fix to allow admins to edit their own profile.
|
143 |
+
* Bug fix for jquery with regards to select2, only load if products are enabled.
|
144 |
+
* Added email API.
|
145 |
+
* Added product attribute to [wpmem_logged_in] shortcode.
|
146 |
+
* Added wpmem_force_ssl() API function.
|
147 |
+
* Added wpmem_set_as_logged_in() API function.
|
148 |
+
* Added filters to remove posts marked hidden from previous/next links.
|
149 |
+
* Updated user login function to use WP script, facilitates login with username OR email, removes wpmem_login_fields filter, changes to wp_safe_redirect().
|
150 |
+
* Updated password change for maintaining login state.
|
151 |
+
* Moved wpmem_fields(), wpmem_form_label(), and wpmem_form_field() to api-forms.php.
|
152 |
+
* Moved wpmem_user_has_role(), wpmem_user_has_meta(), wpmem_is_user_activated(), wpmem_user_data(), wpmem_update_user_role(), and wpmem_user_has_access() to api-users.php.
|
153 |
+
* Moved wpmem_do_excerpt(), wpmem_texturize(), wpmem_get_excluded_meta(), wpmem_use_ssl(), wpmem_write_log(), wpmem_load_dropins(), wpmem_array_insert(), and wpmem_get_sub_str() to api-utilities.php.
|
154 |
+
* Moved wpmem_wp_reserved_terms() to admin API.
|
155 |
+
* Deprecated wpmem_check_activated() and wpmem_use_ssl().
|
156 |
+
* Removed obsolete functions wpmem_enqueue_style(), wpmem_convert_tag(), wpmem_no_reset(), and wpmem_user_profile_multipart().
|
157 |
+
* Applied wpmem_force_ssl() to stylesheet in case it needs to load securely (even if the setting is saved as http://).
|
158 |
|
159 |
= 3.2.2 =
|
160 |
|
161 |
+
* Fixed bug in 3.2.1/3.2.2 for user activation when user creates password at registration and is activated from the user profile.
|
162 |
* Fixed a 3.2 upgrade issue, verifies username field is properly added to field settings array.
|
163 |
* Fixed issue with user product verification where only expiration products were validated.
|
164 |
* Fixed logic in form field builder so multiselect will accept a custom class.
|
wp-members.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP-Members
|
4 |
Plugin URI: https://rocketgeek.com
|
5 |
Description: WP access restriction and user registration. For more information on plugin features, refer to <a href="https://rocketgeek.com/plugins/wp-members/users-guide/">the online Users Guide</a>. A <a href="https://rocketgeek.com/plugins/wp-members/quick-start-guide/">Quick Start Guide</a> is also available. WP-Members(tm) is a trademark of butlerblog.com.
|
6 |
-
Version: 3.2.2
|
7 |
Author: Chad Butler
|
8 |
Author URI: http://butlerblog.com/
|
9 |
Text Domain: wp-members
|
@@ -66,7 +66,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
66 |
}
|
67 |
|
68 |
// Initialize constants.
|
69 |
-
define( 'WPMEM_VERSION', '3.2.2
|
70 |
define( 'WPMEM_DB_VERSION', '2.1.4' );
|
71 |
define( 'WPMEM_DEBUG', false );
|
72 |
define( 'WPMEM_DIR', plugin_dir_url ( __FILE__ ) );
|
3 |
Plugin Name: WP-Members
|
4 |
Plugin URI: https://rocketgeek.com
|
5 |
Description: WP access restriction and user registration. For more information on plugin features, refer to <a href="https://rocketgeek.com/plugins/wp-members/users-guide/">the online Users Guide</a>. A <a href="https://rocketgeek.com/plugins/wp-members/quick-start-guide/">Quick Start Guide</a> is also available. WP-Members(tm) is a trademark of butlerblog.com.
|
6 |
+
Version: 3.2.3.2
|
7 |
Author: Chad Butler
|
8 |
Author URI: http://butlerblog.com/
|
9 |
Text Domain: wp-members
|
66 |
}
|
67 |
|
68 |
// Initialize constants.
|
69 |
+
define( 'WPMEM_VERSION', '3.2.3.2' );
|
70 |
define( 'WPMEM_DB_VERSION', '2.1.4' );
|
71 |
define( 'WPMEM_DEBUG', false );
|
72 |
define( 'WPMEM_DIR', plugin_dir_url ( __FILE__ ) );
|