wpForo Forum - Version 1.7.5

Version Description

Download this release

Release Info

Developer Tomdever
Plugin Icon 128x128 wpForo Forum
Version 1.7.5
Comparing to
See all releases

Code changes from version 1.7.4 to 1.7.5

Files changed (48) hide show
  1. readme.txt +27 -9
  2. wpf-admin/css/admin.css +1 -0
  3. wpf-admin/includes/member-listtable.php +1 -1
  4. wpf-admin/options-tabs/accesses.php +1 -1
  5. wpf-admin/options-tabs/emails.php +1 -0
  6. wpf-admin/options-tabs/features.php +15 -11
  7. wpf-admin/options-tabs/members.php +3 -3
  8. wpf-assets/js/ajax.js +6 -4
  9. wpf-assets/js/frontend.js +5 -5
  10. wpf-assets/js/widgets.js +9 -3
  11. wpf-includes/class-actions.php +6 -5
  12. wpf-includes/class-feed.php +2 -2
  13. wpf-includes/class-forms.php +132 -131
  14. wpf-includes/class-forums.php +3 -2
  15. wpf-includes/class-logs.php +2 -2
  16. wpf-includes/class-members.php +726 -775
  17. wpf-includes/class-permissions.php +15 -15
  18. wpf-includes/class-posts.php +25 -18
  19. wpf-includes/class-revisions.php +2 -2
  20. wpf-includes/class-template.php +667 -232
  21. wpf-includes/class-topics.php +3 -3
  22. wpf-includes/class-usergroups.php +11 -9
  23. wpf-includes/functions-installation.php +29 -11
  24. wpf-includes/functions-integration.php +4 -3
  25. wpf-includes/functions-template.php +151 -95
  26. wpf-includes/functions.php +179 -677
  27. wpf-includes/integration/ultimate-member.php +3 -3
  28. wpf-includes/wpf-hooks.php +44 -43
  29. wpf-languages/wpforo-de_DE.mo +0 -0
  30. wpf-languages/wpforo-de_DE.po +8725 -6545
  31. wpf-languages/wpforo.pot +366 -393
  32. wpf-themes/classic/footer.php +4 -4
  33. wpf-themes/classic/forum.php +1 -1
  34. wpf-themes/classic/index.php +8 -20
  35. wpf-themes/classic/login.php +1 -1
  36. wpf-themes/classic/members.php +4 -4
  37. wpf-themes/classic/post.php +1 -1
  38. wpf-themes/classic/profile-account.php +4 -5
  39. wpf-themes/classic/profile-activity.php +38 -33
  40. wpf-themes/classic/profile-home.php +15 -10
  41. wpf-themes/classic/profile-subscriptions.php +35 -30
  42. wpf-themes/classic/profile.php +22 -22
  43. wpf-themes/classic/recent.php +18 -9
  44. wpf-themes/classic/register.php +1 -1
  45. wpf-themes/classic/search.php +1 -1
  46. wpf-themes/classic/style-rtl.css +8 -8
  47. wpf-themes/classic/style.css +1 -2
  48. wpforo.php +155 -121
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: gVectors Team
3
Tags: forum, forums, forum plugin, WordPress forum plugin, community, discussion
4
Requires at least: 4.1
5
Tested up to: 5.4
6
- Stable tag: 1.7.4
7
Requires PHP: 5.6 and higher
8
License: GPLv2 or later
9
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -165,6 +165,32 @@ Find wpForo forum plugin addons on [gVectors Team website...](https://gvectors.c
165
166
== Changelog ==
167
168
= wpForo Forum 1.7.3 / 1.7.4 | 23.04.2020 =
169
170
[wpForo Forum v1.7.3 / v1.7.4 Release Summary](https://wpforo.com/community/wpforo-announcements/wpforo-1-7-3-is-released/)
@@ -195,14 +221,6 @@ Find wpForo forum plugin addons on [gVectors Team website...](https://gvectors.c
195
* Fixed Bug: new hook to stop conflicts with Page builder plugins, such as Flatsome theme page builder. In this case you should enable the hook with this code: `add_filter('on_wpforo_load_remove_the_content_all_filters', '__return_true');`
196
197
198
- IMPORTANT NOTES for UPDATE
199
-
200
- - After the update, please delete all caches.
201
- - If you have a Minifier/Optimizer plugins please delete all caches.
202
- - If you use CDN and found some issues please purge it.
203
- - Some JS and CSS files are changed, please refresh (press Ctrl+F5) on forum front-end twice to reset browser cache, otherwise you'll see crashed design.
204
-
205
-
206
= wpForo Forum 1.7.2 | 28.03.2020 =
207
208
[wpForo Forum v1.7.2 Release Summary](https://wpforo.com/community/wpforo-announcements/wpforo-1-7-2-is-released/)
3
Tags: forum, forums, forum plugin, WordPress forum plugin, community, discussion
4
Requires at least: 4.1
5
Tested up to: 5.4
6
+ Stable tag: 1.7.5
7
Requires PHP: 5.6 and higher
8
License: GPLv2 or later
9
License URI: https://www.gnu.org/licenses/gpl-2.0.html
165
166
== Changelog ==
167
168
+ = wpForo Forum 1.7.5 | 29.05.2020 =
169
+
170
+ [wpForo Forum v1.7.5 Release Summary](https://wpforo.com/community/wpforo-announcements/wpforo-1-7-5-is-released/)
171
+
172
+ With this version of wpForo, we've improved the [wpForo - User Custom Fields](https://gvectors.com/product/wpforo-user-custom-fields/) addon. Besides the ability to create custom fields for users, now this addon allows you to create Custom Profile Tabs. This is a major change in the addon which required wpForo core update as well.
173
+
174
+ * Added: New permission `Can reply to own topic` in Forum Accesses
175
+ * Added: New `[post-desc]` shortcode for user mentioning email template
176
+ * Added: New merged Profile Page option [ Default | wpForo | BP | UM ]
177
+ * Fixed Bug: Compatibility issues with Rank Math plugin
178
+ * Fixed Bug: User couldn't edit topic title in Threaded Layout
179
+ * Fixed Bug: User couldn't delete own topic if there are some replies in it
180
+ * Fixed Bug: Admin can manage his subscriptions without confirming his email
181
+ * Fixed Bug: PHP Notice; undefined userid in widgets for Banned Users
182
+ * Fixed Bug: Issues with Secondary Usergroups
183
+ * Fixed Bug: Lots of small bugs
184
+
185
+
186
+ IMPORTANT NOTES for UPDATE
187
+
188
+ - After the update, please delete all caches.
189
+ - If you have a Minifier/Optimizer plugins please delete all caches.
190
+ - If you use CDN and found some issues please purge it.
191
+ - Some JS and CSS files are changed, please refresh (press Ctrl+F5) on forum front-end twice to reset browser cache, otherwise you'll see crashed design.
192
+
193
+
194
= wpForo Forum 1.7.3 / 1.7.4 | 23.04.2020 =
195
196
[wpForo Forum v1.7.3 / v1.7.4 Release Summary](https://wpforo.com/community/wpforo-announcements/wpforo-1-7-3-is-released/)
221
* Fixed Bug: new hook to stop conflicts with Page builder plugins, such as Flatsome theme page builder. In this case you should enable the hook with this code: `add_filter('on_wpforo_load_remove_the_content_all_filters', '__return_true');`
222
223
224
= wpForo Forum 1.7.2 | 28.03.2020 =
225
226
[wpForo Forum v1.7.2 Release Summary](https://wpforo.com/community/wpforo-announcements/wpforo-1-7-2-is-released/)
wpf-admin/css/admin.css CHANGED
@@ -166,6 +166,7 @@
166
.wpf-switch-field label:hover {cursor: pointer;}
167
.wpf-switch-field input:checked + label {background-color: #43A6DF; -webkit-box-shadow: none; box-shadow: none; color:#fff;} /* #66DD8D */
168
/* .wpf-switch-field input:last-of-type:checked + label {background-color:#F77059; -webkit-box-shadow: none; box-shadow: none;} */
169
.wpf-switch-field label:first-of-type {border-radius: 4px 0 0 4px;}
170
.wpf-switch-field label:last-of-type {border-radius: 0 4px 4px 0;}
171
166
.wpf-switch-field label:hover {cursor: pointer;}
167
.wpf-switch-field input:checked + label {background-color: #43A6DF; -webkit-box-shadow: none; box-shadow: none; color:#fff;} /* #66DD8D */
168
/* .wpf-switch-field input:last-of-type:checked + label {background-color:#F77059; -webkit-box-shadow: none; box-shadow: none;} */
169
+ .wpf-switch-field input[disabled] + label {opacity: 0.5;} /* #66DD8D */
170
.wpf-switch-field label:first-of-type {border-radius: 4px 0 0 4px;}
171
.wpf-switch-field label:last-of-type {border-radius: 0 4px 4px 0;}
172
wpf-admin/includes/member-listtable.php CHANGED
@@ -79,7 +79,7 @@ class wpForoMembersListTable extends WP_List_Table {
79
**************************************************************************/
80
function column_userid($item){
81
$edit_user = admin_url( 'user-edit.php?user_id=' . intval($item['userid']));
82
- $edit_profile = WPF()->member->get_profile_url($item['userid'], WPF()->tpl->slugs['account']);
83
$ban = wp_nonce_url(admin_url( sprintf('admin.php?page=%1$s&wpfaction=%2$s&userid=%3$s','wpforo-members', 'wpforo_user_ban', $item['userid']) ), 'wpforo-user-ban-' . $item['userid']);
84
$unban = wp_nonce_url(admin_url( sprintf('admin.php?page=%1$s&wpfaction=%2$s&userid=%3$s','wpforo-members', 'wpforo_user_unban', $item['userid']) ), 'wpforo-user-unban-' . $item['userid']);
85
$delete = wp_nonce_url( "users.php?action=delete&user=".intval($item['userid']), 'bulk-users' );
79
**************************************************************************/
80
function column_userid($item){
81
$edit_user = admin_url( 'user-edit.php?user_id=' . intval($item['userid']));
82
+ $edit_profile = WPF()->member->get_profile_url($item['userid'], 'account');
83
$ban = wp_nonce_url(admin_url( sprintf('admin.php?page=%1$s&wpfaction=%2$s&userid=%3$s','wpforo-members', 'wpforo_user_ban', $item['userid']) ), 'wpforo-user-ban-' . $item['userid']);
84
$unban = wp_nonce_url(admin_url( sprintf('admin.php?page=%1$s&wpfaction=%2$s&userid=%3$s','wpforo-members', 'wpforo_user_unban', $item['userid']) ), 'wpforo-user-unban-' . $item['userid']);
85
$delete = wp_nonce_url( "users.php?action=delete&user=".intval($item['userid']), 'bulk-users' );
wpf-admin/options-tabs/accesses.php CHANGED
@@ -3,7 +3,7 @@
3
if( !defined( 'ABSPATH' ) ) exit;
4
if( !WPF()->perm->usergroup_can('ms') ) exit;
5
$nocan = array(
6
- 'no_access' => array('et', 'dt', 'dot', 'er', 'dr', 'dor', 'l', 's', 'at', 'cot', 'p', 'op', 'vp', 'au', 'sv', 'mt', 'ccp' ,'r', 'ct', 'cr', 'eot', 'eor', 'oat', 'osv', 'cvp', 'v', 'a'),
7
'read_only' => array('et', 'dt', 'dot', 'er', 'dr', 'dor', 'l', 's', 'at', 'cot', 'p', 'op', 'vp', 'au', 'sv', 'mt', 'ccp' ,'r'),
8
'standard' => array('et', 'dt', 'er', 'dr', 'at', 'cot', 'p', 'vp', 'au', 'sv', 'mt')
9
);
3
if( !defined( 'ABSPATH' ) ) exit;
4
if( !WPF()->perm->usergroup_can('ms') ) exit;
5
$nocan = array(
6
+ 'no_access' => array('et', 'dt', 'dot', 'er', 'dr', 'dor', 'l', 's', 'at', 'cot', 'p', 'op', 'vp', 'au', 'sv', 'mt', 'ccp' ,'r', 'ct', 'cr', 'ocr', 'eot', 'eor', 'oat', 'osv', 'cvp', 'v', 'a'),
7
'read_only' => array('et', 'dt', 'dot', 'er', 'dr', 'dor', 'l', 's', 'at', 'cot', 'p', 'op', 'vp', 'au', 'sv', 'mt', 'ccp' ,'r'),
8
'standard' => array('et', 'dt', 'er', 'dr', 'at', 'cot', 'p', 'vp', 'au', 'sv', 'mt')
9
);
wpf-admin/options-tabs/emails.php CHANGED
@@ -281,6 +281,7 @@ $wpe_args = array(
281
<li>[author-user-name] - <?php _e('Post author display name', 'wpforo') ?></li>
282
<li>[topic-title] - <?php _e('Topic title', 'wpforo') ?></li>
283
<li>[post-url] - <?php _e('Link to the post', 'wpforo') ?></li>
284
</ul>
285
</th>
286
<td>
281
<li>[author-user-name] - <?php _e('Post author display name', 'wpforo') ?></li>
282
<li>[topic-title] - <?php _e('Topic title', 'wpforo') ?></li>
283
<li>[post-url] - <?php _e('Link to the post', 'wpforo') ?></li>
284
+ <li>[post-desc] - <?php _e('Mentioned post excerpt', 'wpforo') ?></li>
285
</ul>
286
</th>
287
<td>
wpf-admin/options-tabs/features.php CHANGED
@@ -18,8 +18,7 @@ $options = array(
18
'track-logging' => array( 'label' => __('Track Forum and Topic Current Viewers', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1),
19
'goto-unread' => array( 'label' => __('Topic Links Jump to First Unread Post', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('If this option is enabled, all topic links on forums page and on topics page will refer to the first unread post. This behavior is only enabled for logged-in users.', 'wpforo')),
20
'goto-unread-button' => array( 'label' => __('Jump to First Unread Post with [new] Button in Topic Link', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('Adds [new] button at the and of topic links, which jumps to the first unread post.', 'wpforo')),
21
- 'author-link' => array( 'label' => __('Replace Author Link to Forum Profile', 'wpforo'), 'type' => '', 'required' => '', 'value' => 0, 'help' => 'https://wpforo.com/docs/root/wpforo-settings/features/#replace-author-data' ),
22
- 'comment-author-link' => array( 'label' => __('Replace Comment Author Link to Forum Profile', 'wpforo'), 'type' => '', 'required' => '', 'value' => 0, 'help' => 'https://wpforo.com/docs/root/wpforo-settings/features/#replace-author-data' ),
23
'user-register' => array( 'label' => __('Enable User Registration', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('This option is not synced with WordPress "Anyone can register" option in Dashboard > Settings > General admin page. If this option is enabled new users will always be able to register.', 'wpforo'), 'help' => 'https://wpforo.com/docs/root/wpforo-settings/features/#user-registration' ),
24
'user-register-email-confirm' => array( 'label' => __('Enable User Registration email confirmation', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('If you have enabled this option, after registering, user can not login without confirming the email.', 'wpforo'), 'help' => 'https://wpforo.com/docs/root/wpforo-settings/features/#registration-email-confirmation' ),
25
'disable_new_user_admin_notification' => array( 'label' => __('Stop Sending Emails to Admins on New User Registration', 'wpforo'), 'type' => '', 'required' => '', 'value' => 0, 'description' => __('If you have enabled this option, after registering, the admin will not receive an email notification for newly registered user.', 'wpforo'), 'help' => '' ),
@@ -47,10 +46,8 @@ $options = array(
47
'bp_activity' => array( 'label' => __('BuddyPress Activity Integration', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('Posts members activity (new topic, new reply, post like) to BuddyPress Profile Activity page.', 'wpforo')),
48
'bp_notification' => array( 'label' => __('BuddyPress Notification Integration', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('Creates notification on new forum reply in BuddyPress Profile Notification page.', 'wpforo')),
49
'bp_forum_tab' => array( 'label' => __('BuddyPress Profile Forum Tab Integration', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('Adds "Forums" tab with "Created Topics", "Posted Replies", "Liked Posts" and "Subscriptions" sub-tabs to BuddyPress Profile page.', 'wpforo')),
50
- 'bp_profile' => array( 'label' => __('Replace Forum Profile with BuddyPress Profile', 'wpforo'), 'type' => '', 'required' => '', 'value' => 0, 'description' => __('Replaces wpForo Member Profile page with BuddyPress Profile Page.', 'wpforo')),
51
'um_notification' => array( 'label' => __('Ultimate Member Notification Integration', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('Creates notification on new forum reply in Ultimate Member Real-time Notification system.', 'wpforo')),
52
'um_forum_tab' => array( 'label' => __('Ultimate Member Profile Forum Tab Integration', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('Adds "Forums" tab with "Created Topics", "Posted Replies", "Liked Posts" and "Subscriptions" sub-tabs to Ultimate Member Profile page.', 'wpforo')),
53
- 'um_profile' => array( 'label' => __('Replace Forum Profile with Ultimate Member Profile', 'wpforo'), 'type' => '', 'required' => '', 'value' => 0, 'description' => __('Replaces wpForo Member Profile page with Ultimate Member Profile Page.', 'wpforo')),
54
'font-awesome' => array( 'label' => __('Enable wpForo Font-Awesome Lib', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'help' => 'https://wpforo.com/docs/root/wpforo-settings/features/#font-awesome-lib'),
55
'output-buffer' => array( 'label' => __('Enable Output Buffer', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('This feature is useful if you\'re adding content before or after [wpforo] shortcode in page content. Also it useful if forum is loaded before website header, on top of the front-end.', 'wpforo'), 'help' => 'https://wpforo.com/docs/root/wpforo-settings/features/#output-buffer'),
56
'wp-date-format' => array( 'label' => __('Enable WordPress Date/Time Format', 'wpforo'), 'type' => '', 'required' => '', 'value' => 0, 'description' => __('You can manage WordPress date and time format in WordPress Settings > General admin page.', 'wpforo'), 'help' => 'https://wpforo.com/docs/root/wpforo-settings/features/#wp-date'),
@@ -79,14 +76,21 @@ $options = array(
79
</th>
80
<td>
81
<div class="wpf-switch-field">
82
- <?php if( $key == 'font-awesome' ) : ?>
83
- <input type="radio" value="2" name="wpforo_features[<?php echo esc_attr($key); ?>]" id="wpf_<?php echo esc_attr($key); ?>_2" <?php wpfo_check(WPF()->features[$key], 2); ?>><label for="wpf_<?php echo esc_attr($key); ?>_2"><?php _e('Sitewide', 'wpforo'); ?></label> &nbsp;
84
- <input type="radio" value="1" name="wpforo_features[<?php echo esc_attr($key); ?>]" id="wpf_<?php echo esc_attr($key); ?>_1" <?php wpfo_check(WPF()->features[$key], 1); ?>><label for="wpf_<?php echo esc_attr($key); ?>_1"><?php _e('Forum', 'wpforo'); ?></label> &nbsp;
85
<?php else : ?>
86
- <input type="radio" value="1" name="wpforo_features[<?php echo esc_attr($key); ?>]" id="wpf_<?php echo esc_attr($key); ?>_1" <?php wpfo_check(WPF()->features[$key], 1); ?>><label for="wpf_<?php echo esc_attr($key); ?>_1"><?php _e('Yes', 'wpforo'); ?></label> &nbsp;
87
- <?php endif; ?>
88
- <input type="radio" value="0" name="wpforo_features[<?php echo esc_attr($key); ?>]" id="wpf_<?php echo esc_attr($key); ?>_0" <?php wpfo_check(WPF()->features[$key], 0); ?>><label for="wpf_<?php echo esc_attr($key); ?>_0"><?php _e('No', 'wpforo'); ?></label>
89
- <?php if($key == 'copyright') echo '<span style="color:#009900; font-weight:400; font-size:14px;">&nbsp;'. __('Thank you!', 'wpforo') . '</span>'; ?>
90
</div>
91
</td>
92
</tr>
18
'track-logging' => array( 'label' => __('Track Forum and Topic Current Viewers', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1),
19
'goto-unread' => array( 'label' => __('Topic Links Jump to First Unread Post', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('If this option is enabled, all topic links on forums page and on topics page will refer to the first unread post. This behavior is only enabled for logged-in users.', 'wpforo')),
20
'goto-unread-button' => array( 'label' => __('Jump to First Unread Post with [new] Button in Topic Link', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('Adds [new] button at the and of topic links, which jumps to the first unread post.', 'wpforo')),
21
+ 'profile' => array( 'label' => __('Profile Page', 'wpforo'), 'type' => '', 'required' => '', 'value' => 0, 'help' => '' ),
22
'user-register' => array( 'label' => __('Enable User Registration', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('This option is not synced with WordPress "Anyone can register" option in Dashboard > Settings > General admin page. If this option is enabled new users will always be able to register.', 'wpforo'), 'help' => 'https://wpforo.com/docs/root/wpforo-settings/features/#user-registration' ),
23
'user-register-email-confirm' => array( 'label' => __('Enable User Registration email confirmation', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('If you have enabled this option, after registering, user can not login without confirming the email.', 'wpforo'), 'help' => 'https://wpforo.com/docs/root/wpforo-settings/features/#registration-email-confirmation' ),
24
'disable_new_user_admin_notification' => array( 'label' => __('Stop Sending Emails to Admins on New User Registration', 'wpforo'), 'type' => '', 'required' => '', 'value' => 0, 'description' => __('If you have enabled this option, after registering, the admin will not receive an email notification for newly registered user.', 'wpforo'), 'help' => '' ),
46
'bp_activity' => array( 'label' => __('BuddyPress Activity Integration', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('Posts members activity (new topic, new reply, post like) to BuddyPress Profile Activity page.', 'wpforo')),
47
'bp_notification' => array( 'label' => __('BuddyPress Notification Integration', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('Creates notification on new forum reply in BuddyPress Profile Notification page.', 'wpforo')),
48
'bp_forum_tab' => array( 'label' => __('BuddyPress Profile Forum Tab Integration', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('Adds "Forums" tab with "Created Topics", "Posted Replies", "Liked Posts" and "Subscriptions" sub-tabs to BuddyPress Profile page.', 'wpforo')),
49
'um_notification' => array( 'label' => __('Ultimate Member Notification Integration', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('Creates notification on new forum reply in Ultimate Member Real-time Notification system.', 'wpforo')),
50
'um_forum_tab' => array( 'label' => __('Ultimate Member Profile Forum Tab Integration', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('Adds "Forums" tab with "Created Topics", "Posted Replies", "Liked Posts" and "Subscriptions" sub-tabs to Ultimate Member Profile page.', 'wpforo')),
51
'font-awesome' => array( 'label' => __('Enable wpForo Font-Awesome Lib', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'help' => 'https://wpforo.com/docs/root/wpforo-settings/features/#font-awesome-lib'),
52
'output-buffer' => array( 'label' => __('Enable Output Buffer', 'wpforo'), 'type' => '', 'required' => '', 'value' => 1, 'description' => __('This feature is useful if you\'re adding content before or after [wpforo] shortcode in page content. Also it useful if forum is loaded before website header, on top of the front-end.', 'wpforo'), 'help' => 'https://wpforo.com/docs/root/wpforo-settings/features/#output-buffer'),
53
'wp-date-format' => array( 'label' => __('Enable WordPress Date/Time Format', 'wpforo'), 'type' => '', 'required' => '', 'value' => 0, 'description' => __('You can manage WordPress date and time format in WordPress Settings > General admin page.', 'wpforo'), 'help' => 'https://wpforo.com/docs/root/wpforo-settings/features/#wp-date'),
76
</th>
77
<td>
78
<div class="wpf-switch-field">
79
+ <?php if( $key === 'profile' ) : ?>
80
+ <input type="radio" value="1" name="wpforo_features[<?php echo esc_attr($key); ?>]" id="wpf_<?php echo esc_attr($key); ?>_1" <?php wpfo_check(WPF()->features[$key], 1); ?>><label for="wpf_<?php echo esc_attr($key); ?>_1" title="<?php _e('wpForo Profile only for the forum, WordPress Profile for others, including comment authors, post authors and etc...', 'wpforo') ?>"><?php _e('Default', 'wpforo'); ?></label> &nbsp;
81
+ <input type="radio" value="2" name="wpforo_features[<?php echo esc_attr($key); ?>]" id="wpf_<?php echo esc_attr($key); ?>_2" <?php wpfo_check(WPF()->features[$key], 2); ?>><label for="wpf_<?php echo esc_attr($key); ?>_2" title="<?php _e('wpForo Profile for the whole website including forum, comment authors, post authors and etc...', 'wpforo') ?>"><?php _e('wpForo', 'wpforo'); ?></label> &nbsp;
82
+ <input type="radio" value="3" <?php echo !class_exists('BP_Component') ? ' disabled ' : '' ?> name="wpforo_features[<?php echo esc_attr($key); ?>]" id="wpf_<?php echo esc_attr($key); ?>_3" <?php wpfo_check(WPF()->features[$key], 3); ?>><label for="wpf_<?php echo esc_attr($key); ?>_3" title="<?php _e('BuddyPress Profile for the whole website including forum.', 'wpforo') ?>"><?php _e('BuddyPress', 'wpforo'); ?></label> &nbsp;
83
+ <input type="radio" value="4" <?php echo !function_exists('UM') ? ' disabled ' : '' ?> name="wpforo_features[<?php echo esc_attr($key); ?>]" id="wpf_<?php echo esc_attr($key); ?>_4" <?php wpfo_check(WPF()->features[$key], 4); ?>><label for="wpf_<?php echo esc_attr($key); ?>_4" title="<?php _e('Ultimate Member Profile for the whole website including forum.', 'wpforo') ?>"><?php _e('Ultimate Member', 'wpforo'); ?></label> &nbsp;
84
<?php else : ?>
85
+ <?php if( $key === 'font-awesome' ) : ?>
86
+ <input type="radio" value="2" name="wpforo_features[<?php echo esc_attr($key); ?>]" id="wpf_<?php echo esc_attr($key); ?>_2" <?php wpfo_check(WPF()->features[$key], 2); ?>><label for="wpf_<?php echo esc_attr($key); ?>_2"><?php _e('Sitewide', 'wpforo'); ?></label> &nbsp;
87
+ <input type="radio" value="1" name="wpforo_features[<?php echo esc_attr($key); ?>]" id="wpf_<?php echo esc_attr($key); ?>_1" <?php wpfo_check(WPF()->features[$key], 1); ?>><label for="wpf_<?php echo esc_attr($key); ?>_1"><?php _e('Forum', 'wpforo'); ?></label> &nbsp;
88
+ <?php else : ?>
89
+ <input type="radio" value="1" name="wpforo_features[<?php echo esc_attr($key); ?>]" id="wpf_<?php echo esc_attr($key); ?>_1" <?php wpfo_check(WPF()->features[$key], 1); ?>><label for="wpf_<?php echo esc_attr($key); ?>_1"><?php _e('Yes', 'wpforo'); ?></label> &nbsp;
90
+ <?php endif; ?>
91
+ <input type="radio" value="0" name="wpforo_features[<?php echo esc_attr($key); ?>]" id="wpf_<?php echo esc_attr($key); ?>_0" <?php wpfo_check(WPF()->features[$key], 0); ?>><label for="wpf_<?php echo esc_attr($key); ?>_0"><?php _e('No', 'wpforo'); ?></label>
92
+ <?php if($key === 'copyright') echo '<span style="color:#009900; font-weight:400; font-size:14px;">&nbsp;'. __('Thank you!', 'wpforo') . '</span>'; ?>
93
+ <?php endif ?>
94
</div>
95
</td>
96
</tr>
wpf-admin/options-tabs/members.php CHANGED
@@ -67,11 +67,11 @@
67
<p class="wpf-info">
68
<?php _e('For member profile, account and subscription pages use following URLs:', 'wpforo');
69
echo "<br/>";
70
- echo urldecode( wpforo_home_url( WPF()->tpl->slugs['profile'] ) );
71
echo "<br/>";
72
- echo urldecode( wpforo_home_url( WPF()->tpl->slugs['account'] ) );
73
echo "<br/>";
74
- echo urldecode( wpforo_home_url( WPF()->tpl->slugs['subscriptions'] ) );
75
?>
76
</p>
77
</th>
67
<p class="wpf-info">
68
<?php _e('For member profile, account and subscription pages use following URLs:', 'wpforo');
69
echo "<br/>";
70
+ echo urldecode( wpforo_home_url( wpforo_get_template_slug('profile') ) );
71
echo "<br/>";
72
+ echo urldecode( wpforo_home_url( wpforo_get_template_slug('account') ) );
73
echo "<br/>";
74
+ echo urldecode( wpforo_home_url( wpforo_get_template_slug('subscriptions') ) );
75
?>
76
</p>
77
</th>
wpf-assets/js/ajax.js CHANGED
@@ -687,7 +687,7 @@ jQuery(document).ready(function ($) {
687
if( $( "#wpf_user_name" ).length ) { $( "#wpf_user_name" ).attr('name', 'post[name]'); }
688
if( $( "#wpf_user_email" ).length ) { $( "#wpf_user_email" ).attr('name', 'post[email]'); }
689
}else{
690
- $( "#wpf_title").val( response.topic_title );
691
$( "#wpf_tags" ).val( response.topic_tags );
692
$( ".wpf-topic-tags" ).show();
693
$('input[name=wpfaction]', main_form).val('wpforo_topic_save');
@@ -731,9 +731,11 @@ jQuery(document).ready(function ($) {
731
status_value = 'topic';
732
}
733
734
- var forumid = $("input[type='hidden']#wpf_parent").val();
735
-
736
- $.ajax({
737
type: 'POST',
738
url: wpforo.ajax_url,
739
data:{
687
if( $( "#wpf_user_name" ).length ) { $( "#wpf_user_name" ).attr('name', 'post[name]'); }
688
if( $( "#wpf_user_email" ).length ) { $( "#wpf_user_email" ).attr('name', 'post[email]'); }
689
}else{
690
+ $( "#wpf_title").val( response.topic_title ).show();
691
$( "#wpf_tags" ).val( response.topic_tags );
692
$( ".wpf-topic-tags" ).show();
693
$('input[name=wpfaction]', main_form).val('wpforo_topic_save');
731
status_value = 'topic';
732
}
733
734
+ var forumid = 0;
735
+ var wpf_parent = $("input[type='hidden']#wpf_parent");
736
+ if( wpf_parent.length ) forumid = wpf_parent.val();
737
+
738
+ $.ajax({
739
type: 'POST',
740
url: wpforo.ajax_url,
741
data:{
wpf-assets/js/frontend.js CHANGED
@@ -488,10 +488,10 @@ jQuery(document).ready(function($){
488
* prevent multi submitting
489
* disable form elements for 10 seconds
490
*/
491
- var wpforo_prev_submit_time = 0;
492
wpforo_wrap.on('submit', 'form', function () {
493
- if( wpforo_prev_submit_time ){
494
- if( Date.now() - wpforo_prev_submit_time < 10000 ) return false;
495
}else{
496
var textareaid = $(this).data('textareaid');
497
if( textareaid ){
@@ -515,10 +515,10 @@ jQuery(document).ready(function($){
515
}
516
517
wpforo_load_show();
518
- wpforo_prev_submit_time = Date.now();
519
window.onbeforeunload = null;
520
setTimeout(function () {
521
- wpforo_prev_submit_time = 0;
522
wpforo_load_hide();
523
}, 10000);
524
}
488
* prevent multi submitting
489
* disable form elements for 10 seconds
490
*/
491
+ window.wpforo_prev_submit_time = 0;
492
wpforo_wrap.on('submit', 'form', function () {
493
+ if( window.wpforo_prev_submit_time ){
494
+ if( Date.now() - window.wpforo_prev_submit_time < 10000 ) return false;
495
}else{
496
var textareaid = $(this).data('textareaid');
497
if( textareaid ){
515
}
516
517
wpforo_load_show();
518
+ window.wpforo_prev_submit_time = Date.now();
519
window.onbeforeunload = null;
520
setTimeout(function () {
521
+ window.wpforo_prev_submit_time = 0;
522
wpforo_load_hide();
523
}, 10000);
524
}
wpf-assets/js/widgets.js CHANGED
@@ -1,4 +1,8 @@
1
jQuery(document).ready(function ($) {
2
$(document).on("keydown", function (e) {
3
if( e.which === 27 ) $('.wpf-notifications').slideUp(250, 'linear');
4
});
@@ -35,7 +39,7 @@ jQuery(document).ready(function ($) {
35
$('.wpf-notifications').slideUp(250, 'linear');
36
$.ajax({
37
type: 'POST',
38
- url: wpf_widget_ajax_obj.url,
39
data:{
40
foro_n: foro_n,
41
action: 'wpforo_clear_all_notifications'
@@ -76,10 +80,12 @@ function wpforo_bell( wpf_alerts ){
76
77
var wpforo_check_notifications_timeout;
78
function wpforo_check_notifications( wpforo_check_interval ) {
79
var getdata = jQuery('.wpf-notifications').is(':visible');
80
jQuery.ajax({
81
type: 'POST',
82
- url: wpf_widget_ajax_obj.url,
83
data:{
84
getdata: getdata,
85
action: 'wpforo_notifications'
@@ -98,7 +104,7 @@ function wpforo_load_notifications() {
98
jQuery('.wpf-notifications .wpf-notification-content').html('<div class="wpf-nspin"><i class="fas fa-spinner fa-spin"></i></div>');
99
jQuery.ajax({
100
type: 'POST',
101
- url: wpf_widget_ajax_obj.url,
102
data:{
103
getdata: 1,
104
action: 'wpforo_notifications'
1
jQuery(document).ready(function ($) {
2
+ if( parseInt(wpforo_widgets.is_live_notifications_on) && typeof wpforo_check_notifications === 'function'){
3
+ setTimeout(wpforo_check_notifications, parseInt(wpforo_widgets.live_notifications_start), parseInt(wpforo_widgets.live_notifications_interval));
4
+ }
5
+
6
$(document).on("keydown", function (e) {
7
if( e.which === 27 ) $('.wpf-notifications').slideUp(250, 'linear');
8
});
39
$('.wpf-notifications').slideUp(250, 'linear');
40
$.ajax({
41
type: 'POST',
42
+ url: wpforo_widgets.ajax_url,
43
data:{
44
foro_n: foro_n,
45
action: 'wpforo_clear_all_notifications'
80
81
var wpforo_check_notifications_timeout;
82
function wpforo_check_notifications( wpforo_check_interval ) {
83
+ wpforo_check_interval = parseInt(wpforo_check_interval);
84
+ if( isNaN(wpforo_check_interval) ) wpforo_check_interval = 60000;
85
var getdata = jQuery('.wpf-notifications').is(':visible');
86
jQuery.ajax({
87
type: 'POST',
88
+ url: wpforo_widgets.ajax_url,
89
data:{
90
getdata: getdata,
91
action: 'wpforo_notifications'
104
jQuery('.wpf-notifications .wpf-notification-content').html('<div class="wpf-nspin"><i class="fas fa-spinner fa-spin"></i></div>');
105
jQuery.ajax({
106
type: 'POST',
107
+ url: wpforo_widgets.ajax_url,
108
data:{
109
getdata: 1,
110
action: 'wpforo_notifications'
wpf-includes/class-actions.php CHANGED
@@ -399,7 +399,7 @@ class wpForoAction {
399
if( wpfval($_POST, 'member', 'userid') ){
400
wpforo_verify_form();
401
$uid = intval($_POST['member']['userid']);
402
- if( !( intval($_POST['member']['userid']) == WPF()->current_userid ||
403
( WPF()->perm->usergroup_can('em') && WPF()->perm->user_can_manage_user( WPF()->current_userid, $uid )) ) ){
404
WPF()->notice->clear();
405
WPF()->notice->add('Permission denied', 'error');
@@ -489,7 +489,7 @@ class wpForoAction {
489
$redirect_to = wpforo_get_request_uri();
490
if( WPF()->current_object['topic'] && !empty($_POST['wpforo']) && !empty($_POST['wpforo']['target_topic_url']) ){
491
$target_slug = esc_url($_POST['wpforo']['target_topic_url']);
492
- if( preg_match('#^[\r\n\t\s]*https?://[^\r\n\t\s]+?/[^/]+?/([^/]+?)(?:/'. WPF()->tpl->slugs['paged'] .'/\d+/?)?(?:/?\#post-\d+)?/?[\r\n\t\s]*$#isu', $target_slug, $match) ){
493
if( is_wpforo_url($target_slug) ) $target_slug = $match[1];
494
}
495
if ( strpos($target_slug, '/') === false && $target = WPF()->topic->get_topic($target_slug) ){
@@ -525,7 +525,7 @@ class wpForoAction {
525
}else{
526
if( !empty($_POST['wpforo']['target_topic_url']) && !empty($_POST['wpforo']['posts']) ){
527
$target_slug = esc_url( $_POST['wpforo']['target_topic_url'] );
528
- if( preg_match('#^[\r\n\t\s]*https?://[^\r\n\t\s]+?/[^/]+?/([^/]+?)(?:/'. WPF()->tpl->slugs['paged'] .'/\d+/?)?(?:/?\#post-\d+)?/?[\r\n\t\s]*$#isu', $target_slug, $match) )
529
if( is_wpforo_url($target_slug) ) $target_slug = $match[1];
530
if ( strpos($target_slug, '/') === false && $target = WPF()->topic->get_topic($target_slug) ){
531
$append = (empty($_POST['wpforo']['update_date_and_append']) ? 0 : 1);
@@ -579,7 +579,7 @@ class wpForoAction {
579
$all = ( !empty($_POST['wpforo']['check_all']) ? sanitize_title($_POST['wpforo']['check_all']) : '' );
580
581
WPF()->sbscrb->reset($data, $all);
582
- wp_redirect( wpforo_home_url(WPF()->tpl->slugs['subscriptions']) );
583
exit();
584
}
585
@@ -953,7 +953,8 @@ class wpForoAction {
953
if ( ! empty( $_POST['wpforo_tpl_slugs'] ) ) {
954
$wpforo_tpl_slugs = array_filter( array_map( 'sanitize_title', $_POST['wpforo_tpl_slugs'] ) );
955
$wpforo_tpl_slugs = array_merge( WPF()->tpl->slugs, $wpforo_tpl_slugs );
956
- if ( $wpforo_tpl_slugs == ( array_unique( $wpforo_tpl_slugs ) ) ) {
957
update_option( 'wpforo_tpl_slugs', $wpforo_tpl_slugs );
958
} else {
959
WPF()->notice->add( 'Please save "Forum template slugs" uniqueness', 'error' );
399
if( wpfval($_POST, 'member', 'userid') ){
400
wpforo_verify_form();
401
$uid = intval($_POST['member']['userid']);
402
+ if( !( $uid === WPF()->current_userid ||
403
( WPF()->perm->usergroup_can('em') && WPF()->perm->user_can_manage_user( WPF()->current_userid, $uid )) ) ){
404
WPF()->notice->clear();
405
WPF()->notice->add('Permission denied', 'error');
489
$redirect_to = wpforo_get_request_uri();
490
if( WPF()->current_object['topic'] && !empty($_POST['wpforo']) && !empty($_POST['wpforo']['target_topic_url']) ){
491
$target_slug = esc_url($_POST['wpforo']['target_topic_url']);
492
+ if( preg_match('#^[\r\n\t\s]*https?://[^\r\n\t\s]+?/[^/]+?/([^/]+?)(?:/'. wpforo_get_template_slug('paged') .'/\d+/?)?(?:/?\#post-\d+)?/?[\r\n\t\s]*$#isu', $target_slug, $match) ){
493
if( is_wpforo_url($target_slug) ) $target_slug = $match[1];
494
}
495
if ( strpos($target_slug, '/') === false && $target = WPF()->topic->get_topic($target_slug) ){
525
}else{
526
if( !empty($_POST['wpforo']['target_topic_url']) && !empty($_POST['wpforo']['posts']) ){
527
$target_slug = esc_url( $_POST['wpforo']['target_topic_url'] );
528
+ if( preg_match('#^[\r\n\t\s]*https?://[^\r\n\t\s]+?/[^/]+?/([^/]+?)(?:/'. wpforo_get_template_slug('paged') .'/\d+/?)?(?:/?\#post-\d+)?/?[\r\n\t\s]*$#isu', $target_slug, $match) )
529
if( is_wpforo_url($target_slug) ) $target_slug = $match[1];
530
if ( strpos($target_slug, '/') === false && $target = WPF()->topic->get_topic($target_slug) ){
531
$append = (empty($_POST['wpforo']['update_date_and_append']) ? 0 : 1);
579
$all = ( !empty($_POST['wpforo']['check_all']) ? sanitize_title($_POST['wpforo']['check_all']) : '' );
580
581
WPF()->sbscrb->reset($data, $all);
582
+ wp_redirect( wpforo_home_url(wpforo_get_template_slug('subscriptions')) );
583
exit();
584
}
585
953
if ( ! empty( $_POST['wpforo_tpl_slugs'] ) ) {
954
$wpforo_tpl_slugs = array_filter( array_map( 'sanitize_title', $_POST['wpforo_tpl_slugs'] ) );
955
$wpforo_tpl_slugs = array_merge( WPF()->tpl->slugs, $wpforo_tpl_slugs );
956
+ $wpforo_tpl_slugs = array_intersect_key($wpforo_tpl_slugs, WPF()->tpl->default->slugs);
957
+ if ( $wpforo_tpl_slugs == array_unique( $wpforo_tpl_slugs ) ) {
958
update_option( 'wpforo_tpl_slugs', $wpforo_tpl_slugs );
959
} else {
960
WPF()->notice->add( 'Please save "Forum template slugs" uniqueness', 'error' );
wpf-includes/class-feed.php CHANGED
@@ -113,7 +113,7 @@ class wpForoFeed{
113
<?php if(!isset($topic['title']) || !$topic['title']): ?>
114
<?php echo esc_html(WPF()->general_options['title']) . ' - ' . wpforo_phrase('Recent Posts', false); ?>
115
<?php else: ?>
116
- <?php echo esc_html($topic['title']); ?> - <?php echo esc_html($forum['title']); ?>
117
<?php endif; ?>
118
</title>
119
<link><?php echo esc_url($topic['topicurl']); ?></link>
@@ -130,7 +130,7 @@ class wpForoFeed{
130
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', $post['created'], false); ?></pubDate>
131
<description><![CDATA[<?php echo wpforo_removebb(esc_html($post['description'])) ?>]]></description>
132
<content:encoded><![CDATA[<?php echo wpforo_removebb($post['content']) ?>]]></content:encoded>
133
- <?php if($forum['forumurl'] != '#'): ?><category domain="<?php echo esc_url($forum['forumurl']); ?>"><?php echo esc_html($forum['title']); ?></category><?php endif; ?>
134
<dc:creator><?php echo esc_html($post['author']); ?></dc:creator>
135
<guid isPermaLink="true"><?php echo esc_url($post['posturl']); ?></guid>
136
</item>
113
<?php if(!isset($topic['title']) || !$topic['title']): ?>
114
<?php echo esc_html(WPF()->general_options['title']) . ' - ' . wpforo_phrase('Recent Posts', false); ?>
115
<?php else: ?>
116
+ <?php echo esc_html($topic['title']); ?> - <?php echo esc_html(wpfval($forum, 'title')); ?>
117
<?php endif; ?>
118
</title>
119
<link><?php echo esc_url($topic['topicurl']); ?></link>
130
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', $post['created'], false); ?></pubDate>
131
<description><![CDATA[<?php echo wpforo_removebb(esc_html($post['description'])) ?>]]></description>
132
<content:encoded><![CDATA[<?php echo wpforo_removebb($post['content']) ?>]]></content:encoded>
133
+ <?php if(wpfval($forum,'forumurl') != '#'): ?><category domain="<?php echo esc_url(wpfval($forum,'forumurl')); ?>"><?php echo esc_html(wpfval($forum,'title')); ?></category><?php endif; ?>
134
<dc:creator><?php echo esc_html($post['author']); ?></dc:creator>
135
<guid isPermaLink="true"><?php echo esc_url($post['posturl']); ?></guid>
136
</item>
wpf-includes/class-forms.php CHANGED
@@ -41,7 +41,7 @@ class wpForoForm{
41
'html' => '',
42
'varname' => '',
43
'template' => '',
44
- 'canBeInactive' => 1,
45
'canEdit' => array(1),
46
'canView' => array(1, 2, 3, 5),
47
'can' => '',
@@ -53,27 +53,6 @@ class wpForoForm{
53
return wpforo_array_args_cast_and_merge((array) $field, $this->default);
54
}
55
56
- /**
57
- * The varname of custom fields in forms:
58
- * $varname = 'member' user account
59
- * $varname = 'wpfreg' register forms
60
- * $varname = '' member search
61
- * $varname = 'data' custom fields (by default)
62
- *
63
- * @return string
64
- */
65
- public function varname(){
66
- $template = ( isset(WPF()->data['template']) ) ? WPF()->data['template'] : WPF()->current_object['template'];
67
- if( $template === 'members' ){
68
- $varname = WPF()->data['varname'];
69
- } else {
70
- $varname = ( wpfval( WPF()->data, 'varname') ) ? WPF()->data['varname'] : 'data';
71
- $varname = apply_filters( 'wpforo_user_custom_field_varname', $varname);
72
- $varname = ( $varname ) ? $varname : 'data';
73
- }
74
- return $varname;
75
- }
76
-
77
/**
78
* Form builder
79
* for form layout and field building
@@ -106,6 +85,7 @@ class wpForoForm{
106
* @return string field HTML
107
*/
108
public function build_field($args){
109
110
$html = '';
111
if( !is_array($args) || empty($args) ) return '';
@@ -127,16 +107,16 @@ class wpForoForm{
127
}
128
}
129
elseif( $f['template'] === 'profile' ){
130
- if( $this->can_view( $f ) ){
131
$f = $this->esc_field( $f );
132
$html = $this->field_wrap_profile( $field_html, $f );
133
}
134
}
135
elseif( $f['template'] === 'members' ){
136
- $html = $this->field_wrap_members( $field_html, $f );
137
}
138
else{
139
- $html = $this->field_wrap_default( $field_html, $f );
140
}
141
return $html;
142
}
@@ -163,6 +143,7 @@ class wpForoForm{
163
case 'password': $field_html = $this->field_password($f); break;
164
case 'checkbox': $field_html = $this->field_checkbox($f); break;
165
case 'usergroup': $field_html = $this->field_usergroup($f); break;
166
case 'user_nicename': $field_html = $this->field_nicename($f); break;
167
default: $field_html = $this->field_text($f);
168
}
@@ -218,7 +199,7 @@ class wpForoForm{
218
$html .= '<span class="wpf-username">' . $f['value'] . '</span>';
219
$html .= '</div>';
220
}
221
- elseif( !$f['isEditable'] && !$this->can_moderate($f) && WPF()->current_user_groupid !== 1 ){
222
$f = $this->esc_field( $f );
223
$html .= '<div class="wpf-label-wrap">';
224
$html .= '<p class="wpf-label wpfcl-1">' . stripslashes($f['label']) . '</p>';
@@ -252,7 +233,7 @@ class wpForoForm{
252
*/
253
public function field_wrap_profile($field_html, $f){
254
255
- if( $f['type'] !== 'html' && !($f['isRequired'] && $f['isDisplayDefaultValues']) && ( !isset($f['value']) || (!is_numeric($f['value']) && empty($f['value']))) ){
256
return false;
257
}
258
@@ -266,12 +247,12 @@ class wpForoForm{
266
}
267
$html .= '</div>';
268
}
269
- if( isset($f['value']) && !empty($f['value']) ){
270
if( is_array($f['value']) ){
271
$html .= esc_html(implode( ', ', $f['value']));
272
}
273
else{
274
- $f = $this->prepare_values( $f );
275
$html .= '<div class="wpf-field-wrap">';
276
$html .= $f['value'];
277
$html .= '</div>';
@@ -478,28 +459,27 @@ class wpForoForm{
478
* @return string field HTML
479
*/
480
public function field_checkbox($f){
481
- $i = 0; $field_zero = true; $field_html = '';
482
$f['value'] = $this->build_array_value( $f['value'] );
483
if( !is_array($f['values']) ) $f['values'] = $this->build_array_using_string_rows( $f['values'] );
484
if( !empty($f['values']) ){
485
$item_field_name = $f['fieldName'] . '[]';
486
$use_default_selected = (trim($f['isRequired']) && !$f['value']);
487
$f['isRequired'] = ( count($f['values']) == 1 ) ? $f['isRequired'] : '';
488
foreach( $f['values'] as $row ){
489
$item = $this->build_item_value_lable($row);
490
- $field_zero = ( $field_zero === false || $item['value'] == 0 ) ? false : $field_zero;
491
$field_html .= '<div class="wpf-field-item">';
492
$item_html = '<input type="checkbox" ' . ($use_default_selected ? ($item['default_selected'] ? ' checked ' : '') : $this->check($item['value'], $f['value'])) . '
493
name="' . esc_attr( $item_field_name ) . '"
494
value="' . esc_attr( $item['value'] ) . '"
495
- id="' . esc_attr( $f['fieldId'] . '_' . ($i + 1) ) . '"
496
class="wpf-input-checkbox ' . esc_attr( $f['class'] ) . '"
497
' . $f['isDisabled'] . ' ' . $f['isRequired'] . ' ' . $f['attributes'] . '>';
498
- $field_html .= $this->build_label($item['label'], $item_html, $f);
499
$field_html .= '</div>';
500
- $i++;
501
}
502
- if( $field_zero ) $field_html .= '<input type="hidden" name="' . esc_attr( $item_field_name ) . '" value="0">';
503
}
504
return $field_html;
505
}
@@ -518,16 +498,16 @@ class wpForoForm{
518
if( !empty($f['values']) ){
519
foreach( $f['values'] as $row ){
520
$item = $this->build_item_value_lable($row);
521
$field_html .= '<div class="wpf-field-item">';
522
$item_html = '<input type="radio" ' . ($use_default_selected ? ($item['default_selected'] ? ' checked ' : '') : $this->check($item['value'], $f['value'])) . '
523
name="' . esc_attr( $f['fieldName'] ) . '"
524
value="' . esc_attr( $item['value'] ) . '"
525
- id="' . esc_attr( $f['fieldId'] . '_' . ($i + 1) ) . '"
526
class="wpf-input-radio ' . esc_attr( $f['class'] ) . '"
527
' . $f['isDisabled'] . ' ' . $f['isRequired'] . ' ' . $f['attributes'] . ' />';
528
- $field_html .= $this->build_label($item['label'], $item_html, $f);
529
$field_html .= '</div>';
530
- $i++;
531
}
532
}
533
return $field_html;
@@ -597,6 +577,29 @@ class wpForoForm{
597
return $field_html;
598
}
599
600
/**
601
* Avatar - Field builder
602
*
@@ -636,7 +639,7 @@ class wpForoForm{
636
* @return string field HTML
637
*/
638
public function field_html($f){
639
- return stripslashes( do_shortcode( $f['html'] ) );
640
}
641
642
/**
@@ -689,28 +692,29 @@ class wpForoForm{
689
* Prepares displayed values for Profile fields
690
*
691
* @param array $f field arguments
692
* @return array prepared values
693
*/
694
- public function prepare_values($f){
695
switch ( $f['type'] ){
696
case 'textarea':
697
$f['value'] = wpforo_kses(wpforo_decode($f['value']));
698
- break;
699
case 'date':
700
$f['value'] = wpforo_date($f['value'], 'date', false);
701
- break;
702
case 'datetime':
703
$f['value'] = wpforo_date($f['value'], 'datetime', false);
704
- break;
705
case 'url':
706
$f['value'] = sprintf('<a href="%1$s" target="_blank" rel="nofollow">%2$s</a>', $f['value'], $f['value']);
707
- break;
708
case 'email':
709
$f['value'] = sprintf('<a href="mailto:%1$s" rel="nofollow">%2$s</a>', $f['value'], $f['value']);
710
- break;
711
case 'phone':
712
$f['value'] = sprintf('<a href="tel:%1$s" rel="nofollow">%2$s</a>', $f['value'], $f['value']);
713
- break;
714
case 'file':
715
if( !empty($f['value']) ){
716
$wp_upload_dir = wp_upload_dir();
@@ -724,7 +728,15 @@ class wpForoForm{
724
$f['value'] = sprintf('<a href="%s" target="_blank">%s</a>', $file_url, $file_name );
725
}
726
}
727
- break;
728
}
729
switch ( $f['name'] ){
730
case 'skype':
@@ -757,7 +769,8 @@ class wpForoForm{
757
$f['field_class'] = sanitize_text_field( $f['name'] );
758
759
//varname
760
- $f['varname'] = ( !$f['isDefault'] ) ? apply_filters( 'wpforo_user_custom_field_varname', 'data') : $this->varname();
761
762
//template
763
$f['template'] = ( isset(WPF()->data['template']) ) ? WPF()->data['template'] : WPF()->current_object['template'];
@@ -768,21 +781,21 @@ class wpForoForm{
768
$f['value'] = ( isset(WPF()->data['value'][$f['varname']][$f['name']]) ) ? WPF()->data['value'][$f['varname']][$f['name']] : $f['value'];
769
}
770
$f['value'] = wpforo_unslashe( $f['value'] );
771
772
- if( $f['name'] === 'user_nicename' ){
773
$f['value'] = urldecode($f['value']);
774
}
775
776
//allowedGroupIds
777
$groups = array();
778
- if ( !empty($f['allowedGroupIds']) ) {
779
- $groups = $this->build_array_value( $f['allowedGroupIds'] );
780
- }
781
- if ( !$is_owner && wpforo_current_user_is('admin') ){
782
- $groups = WPF()->usergroup->get_usergroups('groupid');
783
- }
784
- if( $is_owner && !in_array(WPF()->current_user_groupid, $f['allowedGroupIds']) ) {
785
- $groups = array();
786
}
787
$f['allowedGroupIds'] = array_filter( $groups );
788
@@ -814,13 +827,18 @@ class wpForoForm{
814
//isDisabled
815
$f['isDisabled'] = ( $f['isDisabled'] ) ? ' disabled="disabled" ' : '';
816
817
- //isMultiChoice
818
- $f['isMultiChoice'] = ( $f['isMultiChoice'] ) ? ' multiple="multiple" ' : '';
819
-
820
//fieldName | new key in args
821
$f['fieldName'] = ( !empty($f['varname'] ) ? $f['varname'] . '[' . $f['name'] . ']' : $f['name'] );
822
823
- //fieldId | new key in args
824
$f['fieldId'] = ( !empty($f['varname'] ) ? $f['varname'] . '_' : '' ) . ( ($f['id']) ? $f['id'] : $f['name'] );
825
826
//minLength & maxLength
@@ -863,6 +881,7 @@ class wpForoForm{
863
}
864
865
public function check($needle, $haystack){
866
return in_array($needle, (array) $haystack) ? 'checked' : '';
867
}
868
@@ -870,24 +889,10 @@ class wpForoForm{
870
return in_array($needle, (array) $haystack) ? 'selected' : '';
871
}
872
873
- public function build_label( $item_label, $item_html, $f ){
874
- $field_html = '';
875
- if ($f['isWrapItem']) {
876
- $field_html .= '<label>';
877
- if ($f['isLabelFirst']) {
878
- $field_html .= '<span class="wpf-' . $f['type'] . '-label">' . stripslashes($item_label) . '</span>&nbsp;' . $item_html;
879
- } else {
880
- $field_html .= $item_html . ' <span class="wpf-' . $f['type'] . '-label">' . stripslashes($item_label) . '</span>';
881
- }
882
- $field_html .= '</label>';
883
- }
884
- else {
885
- if ($f['isLabelFirst']) {
886
- $field_html .= '<span class="wpf-' . $f['type'] . '-label">' . stripslashes($item_label) . '</span>&nbsp;' . $item_html;
887
- } else {
888
- $field_html .= $item_html . ' <span class="wpf-' . $f['type'] . '-label">' . stripslashes($item_label) . '</span>';
889
- }
890
- }
891
return $field_html;
892
}
893
@@ -903,15 +908,18 @@ class wpForoForm{
903
return $item;
904
}
905
906
- public function build_array_value( $var, $sep = ',' ){
907
- if( is_string($var) && !($var = trim($var)) ) return array();
908
- if( is_serialized($var) ) {
909
- $var = unserialize($var);
910
- } elseif( is_string($var) && strpos($var, $sep) !== false ) {
911
- $var = explode($sep, $var);
912
- }
913
- return array_map('trim', (array) $var);
914
- }
915
916
public function build_array_using_string_rows( $string, $regexp = '' ){
917
if( !$regexp ) $regexp = '#' . preg_quote(PHP_EOL) . '#isu';
@@ -999,20 +1007,17 @@ class wpForoForm{
999
$f['value'] = wpforo_trim($f['value']);
1000
if( wpfval($f, 'type') && $f['type'] === 'textarea' ) {
1001
$f['value'] = wpautop( wpforo_kses( stripslashes( $f['value'] ) ) );
1002
- } elseif( $f['type'] === 'select' ){
1003
- $f['value'] = ( $f['name'] === 'timezone' ) ? str_replace('_', ' ', $f['value']) : $f['value'];
1004
- } elseif( wpfval($f, 'type') && $f['type'] === 'checkbox' ) {
1005
- if( wpfval($f, 'value') ){
1006
- if( $f['name'] === 'secondary_groups' ) {
1007
- $f['value'] = WPF()->usergroup->get_secondary_usergroup_names( $f['value'] );
1008
- $f['value'] = implode( ', ', $f['value'] );
1009
- } elseif ( is_array($f['value']) ){
1010
- $f['value'] = array_filter($f['value']);
1011
- $f['value'] = implode( ', ', $f['value'] );
1012
- }
1013
- }
1014
- }
1015
- else{
1016
$f['value'] = esc_html($f['value']);
1017
}
1018
}
@@ -1027,7 +1032,6 @@ class wpForoForm{
1027
$error = array();
1028
$return = array();
1029
$is_owner = $this->owner();
1030
- $varname = $this->varname();
1031
$template = ( isset(WPF()->data['template']) ) ? WPF()->data['template'] : WPF()->current_object['template'];
1032
if( empty($data) ) $error[] = 'No data submitted';
1033
if( empty($fields) ) $error[] = 'User profile fields not found';
@@ -1125,7 +1129,7 @@ class wpForoForm{
1125
}
1126
}
1127
if( wpfval( $field, 'fileSize' ) ){
1128
- if ( wpfval( $_FILES, $varname, 'size', $name ) && $_FILES[ $varname ]['size'][ $name ] > ( $field['fileSize'] * 1024 * 1024 ) ) {
1129
$error[] = $label . ' ' . wpforo_phrase('file is too large', false, false);
1130
$error[] = sprintf( 'Maximum allowed file size is %s MB', $field['fileSize'] );
1131
}
@@ -1150,7 +1154,7 @@ class wpForoForm{
1150
$error[] = 'You have no permission to edit Usergroup field';
1151
}
1152
} else {
1153
- if( $value == 1 || $value == 2 ){
1154
$error[] = 'Admin and Moderator Usergroups are not permitted';
1155
} else {
1156
if( wpfval($field, 'allowedGroupIds') ){
@@ -1165,32 +1169,21 @@ class wpForoForm{
1165
}
1166
}
1167
if( $name === 'secondary_groups' ){
1168
- $secondary_usergroups = WPF()->usergroup->get_secondary_usergroup_ids();
1169
- if( $template !== 'register' ){
1170
- if( WPF()->current_user_groupid != 1 && WPF()->current_user_groupid != 2 ) {
1171
- $error[] = 'You have no permission to edit Usergroup field';
1172
- } else{
1173
- if( !empty($value) && is_array($value) ){
1174
- foreach( $value as $secondary_usergroup_id ){
1175
- if( $secondary_usergroup_id && !in_array( $secondary_usergroup_id, $secondary_usergroups) ){
1176
- $error[] = 'One of the selected Usergroups cannot be set as Secondary';
1177
- }
1178
- }
1179
- }
1180
- }
1181
- } else {
1182
- if( $value == 1 || $value == 2 ){
1183
- $error[] = 'Admin and Moderator Usergroups are not permitted';
1184
- } else {
1185
- if( !empty($value) && is_array($value) ){
1186
- foreach( $value as $secondary_usergroup_id ){
1187
- if( $secondary_usergroup_id && !in_array( $secondary_usergroup_id, $secondary_usergroups) ){
1188
- $error[] = 'One of the selected Usergroups cannot be set as Secondary';
1189
- }
1190
- }
1191
- }
1192
- }
1193
- }
1194
}
1195
}
1196
}
@@ -1324,4 +1317,12 @@ class wpForoForm{
1324
$usergroups_who_can_edit = !empty($f['canEdit']) ? (array) $f['canEdit'] : array(1);
1325
return in_array(WPF()->current_user_groupid, $usergroups_who_can_edit);
1326
}
1327
}
41
'html' => '',
42
'varname' => '',
43
'template' => '',
44
+ 'cantBeInactive' => array(),
45
'canEdit' => array(1),
46
'canView' => array(1, 2, 3, 5),
47
'can' => '',
53
return wpforo_array_args_cast_and_merge((array) $field, $this->default);
54
}
55
56
/**
57
* Form builder
58
* for form layout and field building
85
* @return string field HTML
86
*/
87
public function build_field($args){
88
+ if( is_string($args) ) $args = WPF()->member->get_field($args);
89
90
$html = '';
91
if( !is_array($args) || empty($args) ) return '';
107
}
108
}
109
elseif( $f['template'] === 'profile' ){
110
+ if( $this->can_view( $f ) && $this->can_show_value($f) ){
111
$f = $this->esc_field( $f );
112
$html = $this->field_wrap_profile( $field_html, $f );
113
}
114
}
115
elseif( $f['template'] === 'members' ){
116
+ if( $this->can_show_value($f) ) $html = $this->field_wrap_members( $field_html, $f );
117
}
118
else{
119
+ if( $this->can_show_value($f) ) $html = $this->field_wrap_default( $field_html, $f );
120
}
121
return $html;
122
}
143
case 'password': $field_html = $this->field_password($f); break;
144
case 'checkbox': $field_html = $this->field_checkbox($f); break;
145
case 'usergroup': $field_html = $this->field_usergroup($f); break;
146
+ case 'secondary_groups': $field_html = $this->field_secondary_groups($f); break;
147
case 'user_nicename': $field_html = $this->field_nicename($f); break;
148
default: $field_html = $this->field_text($f);
149
}
199
$html .= '<span class="wpf-username">' . $f['value'] . '</span>';
200
$html .= '</div>';
201
}
202
+ elseif( $f['type'] !== 'password' && !$f['isEditable'] && !$this->can_moderate($f) && WPF()->current_user_groupid !== 1 ){
203
$f = $this->esc_field( $f );
204
$html .= '<div class="wpf-label-wrap">';
205
$html .= '<p class="wpf-label wpfcl-1">' . stripslashes($f['label']) . '</p>';
233
*/
234
public function field_wrap_profile($field_html, $f){
235
236
+ if( !in_array($f['type'], array('html', 'avatar')) && !($f['isRequired'] && $f['isDisplayDefaultValues']) && ( !isset($f['value']) || (!is_numeric($f['value']) && empty($f['value']))) ){
237
return false;
238
}
239
247
}
248
$html .= '</div>';
249
}
250
+ if( $f['type'] === 'avatar' || (isset($f['value']) && !empty($f['value'])) ){
251
if( is_array($f['value']) ){
252
$html .= esc_html(implode( ', ', $f['value']));
253
}
254
else{
255
+ $f = $this->prepare_values( $f, WPF()->current_object['userid'] );
256
$html .= '<div class="wpf-field-wrap">';
257
$html .= $f['value'];
258
$html .= '</div>';
459
* @return string field HTML
460
*/
461
public function field_checkbox($f){
462
+ $i = 0; $field_html = '';
463
$f['value'] = $this->build_array_value( $f['value'] );
464
if( !is_array($f['values']) ) $f['values'] = $this->build_array_using_string_rows( $f['values'] );
465
if( !empty($f['values']) ){
466
$item_field_name = $f['fieldName'] . '[]';
467
$use_default_selected = (trim($f['isRequired']) && !$f['value']);
468
$f['isRequired'] = ( count($f['values']) == 1 ) ? $f['isRequired'] : '';
469
+ $field_html .= '<input type="hidden" name="' . esc_attr( $f['fieldName'] ) . '" value="">';
470
foreach( $f['values'] as $row ){
471
$item = $this->build_item_value_lable($row);
472
+ $id = $f['fieldId'] . '_' . ++$i;
473
$field_html .= '<div class="wpf-field-item">';
474
$item_html = '<input type="checkbox" ' . ($use_default_selected ? ($item['default_selected'] ? ' checked ' : '') : $this->check($item['value'], $f['value'])) . '
475
name="' . esc_attr( $item_field_name ) . '"
476
value="' . esc_attr( $item['value'] ) . '"
477
+ id="' . esc_attr( $id ) . '"
478
class="wpf-input-checkbox ' . esc_attr( $f['class'] ) . '"
479
' . $f['isDisabled'] . ' ' . $f['isRequired'] . ' ' . $f['attributes'] . '>';
480
+ $field_html .= $this->build_label($item['label'], $item_html, $f, $id);
481
$field_html .= '</div>';
482
}
483
}
484
return $field_html;
485
}
498
if( !empty($f['values']) ){
499
foreach( $f['values'] as $row ){
500
$item = $this->build_item_value_lable($row);
501
+ $id = $f['fieldId'] . '_' . ++$i;
502
$field_html .= '<div class="wpf-field-item">';
503
$item_html = '<input type="radio" ' . ($use_default_selected ? ($item['default_selected'] ? ' checked ' : '') : $this->check($item['value'], $f['value'])) . '
504
name="' . esc_attr( $f['fieldName'] ) . '"
505
value="' . esc_attr( $item['value'] ) . '"
506
+ id="' . esc_attr( $id ) . '"
507
class="wpf-input-radio ' . esc_attr( $f['class'] ) . '"
508
' . $f['isDisabled'] . ' ' . $f['isRequired'] . ' ' . $f['attributes'] . ' />';
509
+ $field_html .= $this->build_label($item['label'], $item_html, $f, $id);
510
$field_html .= '</div>';
511
}
512
}
513
return $field_html;
577
return $field_html;
578
}
579
580
+ public function field_secondary_groups($f){
581
+ $field_html = '';
582
+ if( $groups = WPF()->usergroup->get_secondary_usergroups() ){
583
+ $allowed_groupids = (array) wpfval($f, 'allowedGroupIds');
584
+ $i = 0;
585
+ $field_html .= '<input type="hidden" name="' . esc_attr( $f['fieldName'] ) . '" value="">';
586
+ foreach( $groups as $group ){
587
+ if( in_array($group['groupid'], array(1,2,4)) || ( $allowed_groupids && !in_array($group['groupid'], $allowed_groupids) ) ) continue;
588
+ $id = $f['fieldId'] . '_' . ++$i;
589
+ $field_html .= '<div class="wpf-field-item">';
590
+ $item_html = '<input type="checkbox" ' . $this->check($group['groupid'], $f['value']) . '
591
+ name="' . esc_attr( $f['fieldName'] . '[]' ) . '"
592
+ value="' . esc_attr( $group['groupid'] ) . '"
593
+ id="' . esc_attr( $id ) . '"
594
+ class="wpf-input-checkbox ' . esc_attr( $f['class'] ) . '"
595
+ ' . $f['isDisabled'] . ' ' . $f['attributes'] . '>';
596
+ $field_html .= $this->build_label($group['name'], $item_html, $f, $id);
597
+ $field_html .= '</div>';
598
+ }
599
+ }
600
+ return $field_html;
601
+ }
602
+
603
/**
604
* Avatar - Field builder
605
*
639
* @return string field HTML
640
*/
641
public function field_html($f){
642
+ return stripslashes( do_shortcode( wpforo_apply_ucf_shortcode($f['html']) ) );
643
}
644
645
/**
692
* Prepares displayed values for Profile fields
693
*
694
* @param array $f field arguments
695
+ * @param int $userid
696
* @return array prepared values
697
*/
698
+ public function prepare_values($f, $userid = 0){
699
switch ( $f['type'] ){
700
case 'textarea':
701
$f['value'] = wpforo_kses(wpforo_decode($f['value']));
702
+ break;
703
case 'date':
704
$f['value'] = wpforo_date($f['value'], 'date', false);
705
+ break;
706
case 'datetime':
707
$f['value'] = wpforo_date($f['value'], 'datetime', false);
708
+ break;
709
case 'url':
710
$f['value'] = sprintf('<a href="%1$s" target="_blank" rel="nofollow">%2$s</a>', $f['value'], $f['value']);
711
+ break;
712
case 'email':
713
$f['value'] = sprintf('<a href="mailto:%1$s" rel="nofollow">%2$s</a>', $f['value'], $f['value']);
714
+ break;
715
case 'phone':
716
$f['value'] = sprintf('<a href="tel:%1$s" rel="nofollow">%2$s</a>', $f['value'], $f['value']);
717
+ break;
718
case 'file':
719
if( !empty($f['value']) ){
720
$wp_upload_dir = wp_upload_dir();
728
$f['value'] = sprintf('<a href="%s" target="_blank">%s</a>', $file_url, $file_name );
729
}
730
}
731
+ break;
732
+ case 'avatar':
733
+ $f['value'] = (WPF()->perm->usergroup_can('va') && wpforo_feature('avatars')) ? WPF()->member->get_avatar_html($f['value'], $userid) : '';
734
+ break;
735
+ case 'color':
736
+ if($f['value']){
737
+ $f['value'] = '<input type="color" value="'.$f['value'].'" disabled title="'.$f['value'].'" style="min-width: 100px; min-height: 25px;">';
738
+ }
739
+ break;
740
}
741
switch ( $f['name'] ){
742
case 'skype':
769
$f['field_class'] = sanitize_text_field( $f['name'] );
770
771
//varname
772
+ $vn = wpfval( WPF()->data, 'varname');
773
+ $f['varname'] = $f['isDefault'] && $vn ? $vn : 'data';
774
775
//template
776
$f['template'] = ( isset(WPF()->data['template']) ) ? WPF()->data['template'] : WPF()->current_object['template'];
781
$f['value'] = ( isset(WPF()->data['value'][$f['varname']][$f['name']]) ) ? WPF()->data['value'][$f['varname']][$f['name']] : $f['value'];
782
}
783
$f['value'] = wpforo_unslashe( $f['value'] );
784
+ $f['value'] = wpforo_decode( $f['value'] );
785
786
+ if( $f['name'] === 'user_nicename' ){
787
$f['value'] = urldecode($f['value']);
788
}
789
790
//allowedGroupIds
791
$groups = array();
792
+ if ( !empty($f['allowedGroupIds']) ) $groups = $this->build_array_value( $f['allowedGroupIds'] );
793
+ if( $f['type'] === 'usergroup' ){
794
+ if( !$is_owner && wpforo_current_user_is('admin') ){
795
+ $groups = WPF()->usergroup->get_usergroups('groupid');
796
+ }elseif( $is_owner && !in_array(WPF()->current_user_groupid, $f['allowedGroupIds']) ) {
797
+ $groups = array();
798
+ }
799
}
800
$f['allowedGroupIds'] = array_filter( $groups );
801
827
//isDisabled
828
$f['isDisabled'] = ( $f['isDisabled'] ) ? ' disabled="disabled" ' : '';
829
830
//fieldName | new key in args
831
$f['fieldName'] = ( !empty($f['varname'] ) ? $f['varname'] . '[' . $f['name'] . ']' : $f['name'] );
832
833
+ //isMultiChoice
834
+ if( $f['isMultiChoice'] ){
835
+ $f['fieldName'] .= '[]';
836
+ $f['isMultiChoice'] = ' multiple="multiple" ';
837
+ }else{
838
+ $f['isMultiChoice'] = '';
839
+ }
840
+
841
+ //fieldId | new key in args
842
$f['fieldId'] = ( !empty($f['varname'] ) ? $f['varname'] . '_' : '' ) . ( ($f['id']) ? $f['id'] : $f['name'] );
843
844
//minLength & maxLength
881
}
882
883
public function check($needle, $haystack){
884
+ if( is_scalar($haystack) ) $haystack = explode(',', $haystack);
885
return in_array($needle, (array) $haystack) ? 'checked' : '';
886
}
887
889
return in_array($needle, (array) $haystack) ? 'selected' : '';
890
}
891
892
+ public function build_label( $item_label, $item_html, $f, $for = '' ){
893
+ $label = '<span class="wpf-' . $f['type'] . '-label">' . stripslashes($item_label) . '</span>';
894
+ $field_html = $f['isLabelFirst'] ? $label . '&nbsp;' . $item_html : $item_html . '&nbsp;' . $label;
895
+ if( $f['isWrapItem'] ) $field_html = '<label for="' . $for . '">' . $field_html . '</label>';
896
return $field_html;
897
}
898
908
return $item;
909
}
910
911
+ public function build_array_value( $var, $sep = ',' ){
912
+ if( is_scalar($var) ){
913
+ $var = trim($var);
914
+ if( !strlen($var) ) return array();
915
+ }
916
+ if( is_serialized($var) ) {
917
+ $var = unserialize($var);
918
+ } elseif( is_scalar($var) && strpos($var, $sep) !== false ) {
919
+ $var = explode($sep, $var);
920
+ }
921
+ return array_map('trim', (array) $var);
922
+ }
923
924
public function build_array_using_string_rows( $string, $regexp = '' ){
925
if( !$regexp ) $regexp = '#' . preg_quote(PHP_EOL) . '#isu';
1007
$f['value'] = wpforo_trim($f['value']);
1008
if( wpfval($f, 'type') && $f['type'] === 'textarea' ) {
1009
$f['value'] = wpautop( wpforo_kses( stripslashes( $f['value'] ) ) );
1010
+ } elseif( $f['name'] === 'timezone' ){
1011
+ $f['value'] = str_replace('_', ' ', $f['value']);
1012
+ }elseif( $f['fieldKey'] === 'secondary_groups' ) {
1013
+ $f['value'] = WPF()->usergroup->get_secondary_usergroup_names( $f['value'] );
1014
+ $f['value'] = implode( ', ', $f['value'] );
1015
+ }elseif( $f['type'] === 'usergroup' && $f['fieldKey'] === 'groupid' && ($f['value'] = intval( $f['value'] )) ) {
1016
+ if( $group = WPF()->usergroup->get_usergroup( $f['value'] ) ) $f['value'] = wpfval($group, 'name');
1017
+ }elseif( is_array($f['value']) ){
1018
+ $f['value'] = array_filter($f['value']);
1019
+ $f['value'] = implode( ', ', $f['value'] );
1020
+ }else{
1021
$f['value'] = esc_html($f['value']);
1022
}
1023
}
1032
$error = array();
1033
$return = array();
1034
$is_owner = $this->owner();
1035
$template = ( isset(WPF()->data['template']) ) ? WPF()->data['template'] : WPF()->current_object['template'];
1036
if( empty($data) ) $error[] = 'No data submitted';
1037
if( empty($fields) ) $error[] = 'User profile fields not found';
1129
}
1130
}
1131
if( wpfval( $field, 'fileSize' ) ){
1132
+ if ( wpfval( $_FILES, 'data', 'size', $name ) && $_FILES[ 'data' ]['size'][ $name ] > ( $field['fileSize'] * 1024 * 1024 ) ) {
1133
$error[] = $label . ' ' . wpforo_phrase('file is too large', false, false);
1134
$error[] = sprintf( 'Maximum allowed file size is %s MB', $field['fileSize'] );
1135
}
1154
$error[] = 'You have no permission to edit Usergroup field';
1155
}
1156
} else {
1157
+ if( in_array($value, array(1,2,4)) ){
1158
$error[] = 'Admin and Moderator Usergroups are not permitted';
1159
} else {
1160
if( wpfval($field, 'allowedGroupIds') ){
1169
}
1170
}
1171
if( $name === 'secondary_groups' ){
1172
+ if( $template === 'register' || ($is_owner && $field['isEditable']) || ( !$is_owner && in_array(WPF()->current_user_groupid, (array) $field['canEdit']) ) || wpforo_current_user_is('admin') ){
1173
+ if( !empty($value) && is_array($value) ){
1174
+ $secondary_usergroups = WPF()->usergroup->get_secondary_usergroup_ids();
1175
+ foreach( $value as $secondary_usergroup_id ){
1176
+ if( in_array($secondary_usergroup_id, array(1,2,4)) ){
1177
+ $error[] = 'Admin and Moderator Usergroups are not permitted';
1178
+ }
1179
+ if( $secondary_usergroup_id && !in_array( $secondary_usergroup_id, $secondary_usergroups) ){
1180
+ $error[] = 'One of the selected Usergroups cannot be set as Secondary';
1181
+ }
1182
+ }
1183
+ }
1184
+ }else{
1185
+ $error[] = 'You have no permission to edit Usergroup field';
1186
+ }
1187
}
1188
}
1189
}
1317
$usergroups_who_can_edit = !empty($f['canEdit']) ? (array) $f['canEdit'] : array(1);
1318
return in_array(WPF()->current_user_groupid, $usergroups_who_can_edit);
1319
}
1320
+
1321
+ public function can_show_value($f){
1322
+ $return = true;
1323
+ if( is_string($f) ) $f = WPF()->member->get_field($f);
1324
+ $f = wpforo_parse_args($f, $this->default);
1325
+ if( $f['type'] === 'password' ) $return = false;
1326
+ return apply_filters('wpforo_form_can_show_value', $return, $f);
1327
+ }
1328
}
wpf-includes/class-forums.php CHANGED
@@ -45,6 +45,7 @@ class wpForoForum{
45
'et' => __('Can edit topic', 'wpforo'),
46
'dt' => __('Can delete topic', 'wpforo'),
47
'cr' => __('Can post reply', 'wpforo'),
48
'vr' => __('Can view replies', 'wpforo'),
49
'er' => __('Can edit replies', 'wpforo'),
50
'dr' => __('Can delete replies', 'wpforo'),
@@ -104,14 +105,14 @@ class wpForoForum{
104
$new_slug = wpforo_text($slug, 250, false);
105
$forumid = intval($forumid);
106
$i = 2;
107
- while( WPF()->db->get_var("SELECT `forumid` FROM ".WPF()->tables->forums." WHERE `slug` = '" . esc_sql($new_slug) . "'" . ($forumid ? ' AND `forumid` != '. intval($forumid) : '')) ){
108
if( !isset($parent_slug) && $parentid = intval($parentid) ){
109
$parent_slug = WPF()->db->get_var("SELECT `slug` FROM ".WPF()->tables->forums." WHERE `forumid` = " . intval($parentid) );
110
$new_slug = $parent_slug . "-" . wpforo_text($slug, 250, false);
111
}else{
112
$new_slug = wpforo_text($slug, 250, false) . '-' . $i;
113
}
114
- $i++;
115
}
116
return $new_slug;
117
}
45
'et' => __('Can edit topic', 'wpforo'),
46
'dt' => __('Can delete topic', 'wpforo'),
47
'cr' => __('Can post reply', 'wpforo'),
48
+ 'ocr' => __('Can reply to own topic', 'wpforo'),
49
'vr' => __('Can view replies', 'wpforo'),
50
'er' => __('Can edit replies', 'wpforo'),
51
'dr' => __('Can delete replies', 'wpforo'),
105
$new_slug = wpforo_text($slug, 250, false);
106
$forumid = intval($forumid);
107
$i = 2;
108
+ while( !WPF()->can_use_this_slug($new_slug) || WPF()->db->get_var("SELECT `forumid` FROM ".WPF()->tables->forums." WHERE `slug` = '" . esc_sql($new_slug) . "'" . ($forumid ? ' AND `forumid` != '. intval($forumid) : '')) ){
109
if( !isset($parent_slug) && $parentid = intval($parentid) ){
110
$parent_slug = WPF()->db->get_var("SELECT `slug` FROM ".WPF()->tables->forums." WHERE `forumid` = " . intval($parentid) );
111
$new_slug = $parent_slug . "-" . wpforo_text($slug, 250, false);
112
}else{
113
$new_slug = wpforo_text($slug, 250, false) . '-' . $i;
114
+ $i++;
115
}
116
}
117
return $new_slug;
118
}
wpf-includes/class-logs.php CHANGED
@@ -271,8 +271,8 @@ class wpForoLogs{
271
update_user_meta( WPF()->current_userid, 'wpf_read_topics', array() );
272
}
273
wpforo_setcookie( 'wpf_all_read', $last );
274
- wpforo_setcookie( 'wpf_read_forums', '' );
275
- wpforo_setcookie( 'wpf_read_topics', '' );
276
}
277
278
public function get_all_read( $item ){
271
update_user_meta( WPF()->current_userid, 'wpf_read_topics', array() );
272
}
273
wpforo_setcookie( 'wpf_all_read', $last );
274
+ wpforo_setcookie( 'wpf_read_forums' );
275
+ wpforo_setcookie( 'wpf_read_topics' );
276
}
277
278
public function get_all_read( $item ){
wpf-includes/class-members.php CHANGED
@@ -92,7 +92,7 @@ class wpForoMember{
92
$sql = WPF()->db->prepare(
93
$sql,
94
$userid,
95
- ( isset($title) && $title ? $title : WPF()->member->options['default_title'] ),
96
sanitize_user($username),
97
intval((isset($groupid) && $groupid ? $groupid : WPF()->usergroup->default_groupid)),
98
(isset($site) ? sanitize_text_field($site) : '' ),
@@ -121,19 +121,18 @@ class wpForoMember{
121
//-- START -- copied from update code
122
//Define $user
123
$user = $user_fields;
124
- $varname = WPF()->form->varname();
125
126
//Define $userid
127
$userid = intval( wpfval($user, 'userid') );
128
129
//Check custom fields and merge to $user array
130
- if( wpfval($data, $varname) && is_array($data[$varname]) && !empty($data[$varname]) ){
131
- $custom_fields = $data[$varname];
132
$user = array_merge( $custom_fields, $user );
133
}
134
135
//Check file uploading custom fields and merge to $user array
136
- $file_data = isset($_FILES[$varname]['name']) && $_FILES[$varname]['name'] && is_array($_FILES[$varname]['name']) ? array_filter($_FILES[$varname]['name']) : array();
137
$file_fields = WPF()->form->prepare_file_args( $file_data, $userid );
138
if( wpfval( $file_fields, 'fields') ) {
139
$user = array_merge( $file_fields['fields'], $user );
@@ -281,7 +280,7 @@ class wpForoMember{
281
/**
282
* @deprecated since 1.5.0
283
* @deprecated No longer used by core and not recommended.
284
- * @deprecated Use WPF()->member->update()
285
*/
286
function edit( $args = array() ){
287
if( empty($args) && empty($_REQUEST['member']) ) return FALSE;
@@ -374,8 +373,8 @@ class wpForoMember{
374
/**
375
* @deprecated since 1.5.0
376
* @deprecated No longer used by core and not recommended.
377
- * @deprecated Use WPF()->member->update()
378
- * @deprecated Or use WPF()->member->update_profile_field() for one field update
379
*/
380
function edit_profile($args){
381
if(empty($args)) return FALSE;
@@ -512,7 +511,7 @@ class wpForoMember{
512
*
513
* $data['member']['userid'] or $data['userid'] is required
514
*
515
- * @param string $type User data update types (comma separated)
516
* $type = 'full' user fields, profile fields, custom fields
517
* $type = 'user' only user fields (wp_users table)
518
* $type = 'profile' only profile fields (wp_wpforo_profiles table)
@@ -524,44 +523,33 @@ class wpForoMember{
524
* @return false|array wpForo User array
525
*/
526
public function update( $data, $type = 'full', $check_permissions = true ){
527
-
528
- $type = explode(',', $type);
529
- $type = array_map('trim', $type );
530
- $varname = WPF()->form->varname();
531
- $template = (wpfval(WPF()->current_object, 'template')) ? WPF()->current_object['template'] : false;
532
-
533
- if( $template == 'account' ){
534
- $form = 'member';
535
- $form_fields = $this->get_account_fields();
536
- } elseif( $template == 'register' ){
537
- $form = 'wpfreg';
538
- $form_fields = $this->get_register_fields();
539
- } else{
540
- $form = 'member';
541
- $form_fields = $this->get_account_fields();
542
- $form = apply_filters( 'wpforo_user_update_form', $form );
543
- $form_fields = apply_filters( 'wpforo_user_update_fields', $form_fields );
544
- }
545
-
546
- if( !$form ){ WPF()->notice->add( 'Form name not found', 'error'); return false; }
547
if( !$form_fields ){ WPF()->notice->add( 'Form template not found', 'error'); return false; }
548
549
if( !wpfkey($data, $form) ){
550
- if( in_array('custom_fields', $type) && count($type) == 1 ){
551
- if( !wpfval($data, $varname) ){
552
- $data[ $varname ] = $data;
553
- if( wpfkey($data, $varname, 'userid') ) unset($data[ $varname ]['userid']);
554
}
555
} else {
556
$data[ $form ] = $data;
557
}
558
}
559
- if( wpfval($data, 'userid') && !wpfval($data, $form, 'userid') ){
560
- $data[ $form ]['userid'] = $data['userid'];
561
- }
562
563
if( wpfval($data, $form, 'userid') ){
564
-
565
$result_user = true;
566
$result_fields = true;
567
$result_profile = true;
@@ -577,13 +565,13 @@ class wpForoMember{
577
if( $check_permissions ) WPF()->perm->can_edit_user( $userid );
578
579
//Check custom fields and merge to $user array
580
- if( wpfval($data, $varname) && is_array($data[$varname]) && !empty($data[$varname]) ){
581
- $custom_fields = $data[$varname];
582
$user = array_merge( $custom_fields, $user );
583
}
584
585
//Check file uploading custom fields and merge to $user array
586
- $file_data = isset($_FILES[$varname]['name']) && $_FILES[$varname]['name'] && is_array($_FILES[$varname]['name']) ? array_filter($_FILES[$varname]['name']) : array();
587
$file_fields = WPF()->form->prepare_file_args( $file_data, $userid );
588
if( wpfval( $file_fields, 'fields') ) {
589
$user = array_merge( $file_fields['fields'], $user );
@@ -634,12 +622,12 @@ class wpForoMember{
634
$result_password = false;
635
}
636
if( $result_password && wpfval($user, 'old_pass') && wpfval($user, 'user_pass1') ){
637
- $result_password = WPF()->member->change_password( $user['old_pass'], $user['user_pass1'], $userid );
638
}
639
640
//Upload avatar
641
- if( wpfval($user, 'avatar_type') && $user['avatar_type'] == 'custom' ){
642
- WPF()->member->upload_avatar( $userid );
643
}
644
645
//Update Custom Fields
@@ -814,10 +802,10 @@ class wpForoMember{
814
$profile_fields['avatar'] = '';
815
$profile_fields_types[] = '%s';
816
}
817
- if( wpfkey($data, 'secondary_groups') && is_array($data['secondary_groups']) ){
818
- $data['secondary_groups'] = array_filter($data['secondary_groups']);
819
- $profile_fields['secondary_groups'] = implode( ',', $data['secondary_groups'] );
820
- $profile_fields_types[] = '%s';
821
}
822
if( wpfkey($data, 'rank') ){
823
$profile_fields['rank'] = $data['rank'];
@@ -978,10 +966,9 @@ class wpForoMember{
978
979
public function upload_files( $file_fields ){
980
if ( !empty( $file_fields ) ) {
981
- $varname = WPF()->form->varname();
982
foreach( $file_fields as $field_name => $file_path ) {
983
- if( wpfval( $_FILES, $varname, 'tmp_name', $field_name ) &&
984
- !move_uploaded_file( $_FILES[ $varname ]['tmp_name'][$field_name], $file_path )
985
) {
986
WPF()->notice->add('Sorry, there was an error uploading attached file', 'error');
987
}
@@ -1050,7 +1037,7 @@ class wpForoMember{
1050
1051
public function synchronize_user($userid, $roles_usergroups = array()){
1052
$groupid = false;
1053
- if(!$userid) return FALSE;
1054
$user = get_userdata($userid);
1055
1056
//Don't synchronize User Roles with Usergroups if the option is disabled
@@ -1079,7 +1066,7 @@ class wpForoMember{
1079
$insert_groupid = ( isset($_POST['wpforo_usergroup']) && !wpforo_feature('role-synch') ) ? intval($_POST['wpforo_usergroup']) : $groupid;
1080
$insert_timezone = (isset($_POST['wpforo_usertimezone'])) ? sanitize_text_field($_POST['wpforo_usertimezone']) : '';
1081
$about = get_user_meta( $userid, 'description', true );
1082
- return $this->add_profile(
1083
array( 'userid' => wpforo_bigintval($userid),
1084
'username' => sanitize_user($user->user_login),
1085
'groupid' => intval($insert_groupid),
@@ -1087,6 +1074,11 @@ class wpForoMember{
1087
'timezone' => sanitize_text_field($insert_timezone),
1088
'about' => stripslashes( wpforo_kses(trim($about), 'user_description') ),
1089
'last_login' => sanitize_text_field($user->user_registered) ) );
1090
}
1091
1092
public function synchronize_users($limit = NULL){
@@ -1173,9 +1165,9 @@ class wpForoMember{
1173
1174
if(!empty($member)) {
1175
$member['profile_url'] = $this->profile_url( $member );
1176
- if( !wpfval($member, 'stat') ) {
1177
- $member['stat'] = $this->get_stat( $member, false, true );
1178
- }
1179
if( $do_db_cache ){
1180
if(!$user_meta_obj) update_user_meta( $userid, '_wpf_member_obj', $member );
1181
}
@@ -1360,7 +1352,7 @@ class wpForoMember{
1360
1361
if( !($reassign = intval($reassign)) ){
1362
if( $postids = WPF()->db->get_col( WPF()->db->prepare( "SELECT `postid` FROM `".WPF()->tables->posts."` WHERE userid = %d", $userid ) ) ){
1363
- foreach( $postids as $postid ) WPF()->post->delete($postid);
1364
}
1365
1366
if( $topicids = WPF()->db->get_col( WPF()->db->prepare( "SELECT `topicid` FROM `".WPF()->tables->topics."` WHERE userid = %d", $userid ) ) ){
@@ -1461,20 +1453,13 @@ class wpForoMember{
1461
$cache = WPF()->cache->on('memory_cashe');
1462
1463
if($cache && isset(self::$cache['avatar'][$userid])){
1464
- if(self::$cache['avatar'][$userid]['attr'] == $attr && self::$cache['avatar'][$userid]['size'] == $size){
1465
if(isset(self::$cache['avatar'][$userid]['img'])){
1466
return self::$cache['avatar'][$userid]['img'];
1467
}
1468
}
1469
}
1470
- $src = $this->get_avatar_url($userid);
1471
- if($src && wpforo_feature('custom-avatars')){
1472
- $attr = ($attr ? $attr : 'height="96" width="96"');
1473
- $img = '<img class="avatar" src="'.esc_url($src).'" '. $attr .' />';
1474
- }else{
1475
- $img = ($size) ? get_avatar($userid, $size) : get_avatar($userid);
1476
- if($attr) $img = str_replace('<img', '<img ' . $attr, $img);
1477
- }
1478
if($cache){
1479
self::$cache['avatar'][$userid]['attr'] = $attr;
1480
self::$cache['avatar'][$userid]['size'] = $size;
@@ -1500,6 +1485,17 @@ class wpForoMember{
1500
return $avatar_url;
1501
}
1502
1503
public function get_topics_count( $userid ){
1504
$count = WPF()->db->get_var("SELECT count(topicid) FROM `".WPF()->tables->topics."` WHERE `userid` = ".intval($userid));
1505
return $count;
@@ -1549,20 +1545,20 @@ class wpForoMember{
1549
1550
public function get_profile_url( $arg, $template = 'profile' ){
1551
if(!$arg) return wpforo_home_url();
1552
- $template_slug = ( wpfkey( WPF()->tpl->slugs, $template ) ? WPF()->tpl->slugs[$template] : $template );
1553
$userid = intval( basename($arg) );
1554
$member_args = ( $userid ? $userid : array( 'user_nicename' => basename($arg) ) );
1555
$user = $this->get_member( $member_args );
1556
if(empty($user)) return wpforo_home_url();
1557
- $user_slug = ( wpfo(WPF()->member->options['url_structure'], false) === 'id' ? $user['ID'] : $user['user_nicename'] );
1558
$profile_url = wpforo_home_url("$template_slug/$user_slug");
1559
return apply_filters('wpforo_member_profile_url', $profile_url, $user, $template);
1560
}
1561
1562
public function profile_url( $member = array(), $template = 'profile' ){
1563
- $template_slug = ( wpfkey( WPF()->tpl->slugs, $template ) ? WPF()->tpl->slugs[$template] : $template );
1564
if(isset($member['ID']) || isset($member['user_nicename'])){
1565
- $user_slug = ( wpfo(WPF()->member->options['url_structure'], false) === 'id' ? $member['ID'] : $member['user_nicename'] );
1566
$profile_url = wpforo_home_url("$template_slug/$user_slug");
1567
$profile_url = apply_filters( 'wpforo_profile_url', $profile_url, $member, $template );
1568
}
@@ -1666,7 +1662,7 @@ class wpForoMember{
1666
}
1667
1668
public function is_online( $userid, $duration = NULL ){
1669
- if(!$duration) $duration = WPF()->member->options['online_status_timeout'];
1670
1671
$cache = WPF()->cache->on('memory_cashe');
1672
@@ -1714,7 +1710,7 @@ class wpForoMember{
1714
}
1715
1716
public function online_members_count( $duration = NULL ){
1717
- if(!$duration) $duration = WPF()->member->options['online_status_timeout'];
1718
$current_time = current_time( 'timestamp', 1 );
1719
$online_timeframe = $current_time - $duration;
1720
$online = WPF()->db->get_var( "SELECT COUNT(DISTINCT `userid`, `ip`) AS total FROM `".WPF()->tables->visits."` WHERE `time` > " . intval($online_timeframe) );
@@ -1723,7 +1719,7 @@ class wpForoMember{
1723
}
1724
1725
public function get_online_members( $count = 1, $groupids = array(), $duration = NULL ){
1726
- if(!$duration) $duration = WPF()->member->options['online_status_timeout'];
1727
$current_time = current_time( 'timestamp', 1 );
1728
$online_timeframe = $current_time - $duration;
1729
$groupids = array_filter( wpforo_parse_args($groupids) );
@@ -1749,17 +1745,17 @@ class wpForoMember{
1749
$rating['title'] = array( 0 => 'New Member', 1 => 'Active Member', 2 => 'Eminent Member', 3 => 'Trusted Member', 4 => 'Estimable Member', 5 => 'Reputable Member', 6 => 'Honorable Member', 7 => 'Prominent Member', 8 => 'Noble Member', 9 => 'Famed Member', 10 => 'Illustrious Member' );
1750
$rating['icon'] = array( 0 => 'far fa-star-half', 1 => 'fas fa-star', 2 => 'fas fa-star', 3 => 'fas fa-star', 4 => 'fas fa-star', 5 => 'fas fa-star', 6 => 'fas fa-certificate', 7 => 'fas fa-certificate', 8 => 'fas fa-certificate', 9 => 'fas fa-shield-alt', 10 => 'fas fa-trophy' );
1751
1752
- if(!empty(WPF()->member->options['rating'])){
1753
1754
- if($level === false) return WPF()->member->options['rating'];
1755
- if(!empty(WPF()->member->options['rating'][$level])){
1756
1757
- if(!$var) return WPF()->member->options['rating'][$level];
1758
- if(!empty(WPF()->member->options['rating'][$level][$var])){
1759
1760
- if( $var == 'icon' && strpos( WPF()->member->options['rating'][$level][$var], ' ' ) === false ) return $rating[$var][$level];
1761
1762
- return WPF()->member->options['rating'][$level][$var];
1763
}
1764
}
1765
}
@@ -1855,16 +1851,13 @@ class wpForoMember{
1855
$user = $this->get_member( $current_user->ID );
1856
}
1857
$user_meta = get_user_meta( $current_user->ID );
1858
- $status = ( isset($user['status']) ? $user['status'] : '' );
1859
- if( !in_array( $status, array('banned', 'trashed')) ){
1860
- $user['groupid'] = intval($user['groupid']);
1861
- WPF()->current_user = $user;
1862
- WPF()->current_usermeta = $user_meta;
1863
- WPF()->current_user_groupid = WPF()->current_user['groupid'];
1864
- WPF()->current_user_secondary_groupids = ( wpfkey(WPF()->current_user, 'secondary_groups') ) ? WPF()->current_user['secondary_groups'] : '';
1865
- $this->update_online_time();
1866
- }
1867
- WPF()->current_user_status = $status;
1868
}elseif ( $guest = $this->get_guest_cookies() ){
1869
WPF()->current_user = $this->get_guest($guest);
1870
WPF()->current_user_email = $guest['email'];
@@ -2042,617 +2035,502 @@ class wpForoMember{
2042
2043
}
2044
2045
- public function init_fields(){
2046
- if( !empty($this->fields) ) return;
2047
2048
- $this->init_countries();
2049
- $this->init_timezones();
2050
2051
- $this->fields = apply_filters('wpforo_member_before_init_fields', $this->fields);
2052
2053
- $usergroupids = array();
2054
- $secondary_groups = '';
2055
- $usergroups = WPF()->usergroup->get_usergroups();
2056
- foreach( $usergroups as $usergroup ){
2057
- $usergroupids[] = $usergroup['groupid'];
2058
- if( $usergroup['groupid'] != 1 && $usergroup['secondary'] ){
2059
- $secondary_groups .= $usergroup['groupid'] . '=>' . $usergroup['name'] . "\r\n";
2060
- }
2061
- }
2062
- $usergroupids_can_edit_fields = WPF()->perm->usergroups_can('em');
2063
- $usergroupids_can_view_social_net = WPF()->perm->usergroups_can('vmsn');
2064
-
2065
- $this->fields['user_login'] = array(
2066
- 'fieldKey' => 'user_login',
2067
- 'type' => 'text',
2068
- 'isDefault' => 1,
2069
- 'isRemovable' => 0,
2070
- 'isRequired' => 1,
2071
- 'isEditable' => 0,
2072
- 'label' => wpforo_phrase('Username', false),
2073
- 'title' => wpforo_phrase('Username', false),
2074
- 'placeholder' => wpforo_phrase('Username', false),
2075
- 'description' => wpforo_phrase('Length must be between 3 characters and 15 characters.', false),
2076
- 'minLength' => $this->default->login_min_length,
2077
- 'maxLength' => $this->default->login_max_length,
2078
- 'faIcon' => 'fas fa-user',
2079
- 'name' => 'user_login',
2080
- 'canBeInactive' => array(
2081
- 'account',
2082
- 'profile',
2083
- 'search'
2084
- ),
2085
- 'canEdit' => array(),
2086
- 'canView' => WPF()->perm->usergroups_can('vmu'),
2087
- 'can' => 'vmu',
2088
- 'isSearchable' => 0
2089
- );
2090
2091
- $this->fields['user_email'] = array(
2092
- 'fieldKey' => 'user_email',
2093
- 'type' => 'email',
2094
- 'isDefault' => 1,
2095
- 'isRemovable' => 0,
2096
- 'isRequired' => 1,
2097
- 'isEditable' => 1,
2098
- 'label' => wpforo_phrase('Email', false),
2099
- 'title' => wpforo_phrase('Email', false),
2100
- 'placeholder' => wpforo_phrase('Email', false),
2101
- 'minLength' => 0,
2102
- 'maxLength' => 0,
2103
- 'faIcon' => 'fas fa-envelope',
2104
- 'name' => 'user_email',
2105
- 'canBeInactive' => array(
2106
- 'account',
2107
- 'profile',
2108
- 'search'
2109
- ),
2110
- 'canEdit' => $usergroupids_can_edit_fields,
2111
- 'canView' => WPF()->perm->usergroups_can('vmm'),
2112
- 'can' => 'vmm',
2113
- 'isSearchable' => 1
2114
- );
2115
2116
- $this->fields['user_pass'] = array(
2117
- 'fieldKey' => 'user_pass',
2118
- 'type' => 'password',
2119
- 'isDefault' => 1,
2120
- 'isRemovable' => 0,
2121
- 'isRequired' => 1,
2122
- 'isEditable' => 1,
2123
- 'label' => wpforo_phrase('Password', false),
2124
- 'title' => wpforo_phrase('Password', false),
2125
- 'placeholder' => wpforo_phrase('Password', false),
2126
- 'description' => wpforo_phrase('Must be minimum 6 characters.', false),
2127
- 'minLength' => $this->default->pass_min_length,
2128
- 'maxLength' => $this->default->pass_max_length,
2129
- 'faIcon' => 'fas fa-key',
2130
- 'name' => 'user_pass',
2131
- 'canBeInactive' => array(
2132
- 'profile',
2133
- 'search'
2134
- ),
2135
- 'canEdit' => $usergroupids_can_edit_fields,
2136
- 'canView' => array(),
2137
- 'can' => '',
2138
- 'isSearchable' => 0
2139
- );
2140
2141
- $this->fields['display_name'] = array(
2142
- 'fieldKey' => 'display_name',
2143
- 'type' => 'text',
2144
- 'isDefault' => 1,
2145
- 'isRemovable' => 0,
2146
- 'isRequired' => 1,
2147
- 'isEditable' => 1,
2148
- 'label' => wpforo_phrase('Display Name', false),
2149
- 'title' => wpforo_phrase('Display Name', false),
2150
- 'placeholder' => wpforo_phrase('Display Name', false),
2151
- 'faIcon' => 'fas fa-user',
2152
- 'name' => 'display_name',
2153
- 'canBeInactive' => array(
2154
- 'profile',
2155
- 'search'
2156
- ),
2157
- 'canEdit' => $usergroupids_can_edit_fields,
2158
- 'canView' => $usergroupids,
2159
- 'can' => '',
2160
- 'isSearchable' => 1
2161
- );
2162
2163
- $this->fields['user_nicename'] = array(
2164
- 'fieldKey' => 'user_nicename',
2165
- 'type' => 'text',
2166
- 'isDefault' => 1,
2167
- 'isRemovable' => 0,
2168
- 'isRequired' => 1,
2169
- 'isEditable' => 1,
2170
- 'label' => wpforo_phrase('Nickname', false),
2171
- 'title' => wpforo_phrase('Nickname', false),
2172
- 'placeholder' => wpforo_phrase('Nickname', false),
2173
- 'description' => wpforo_phrase('URL Address Identifier', false),
2174
- 'minLength' => 0,
2175
- 'maxLength' => 0,
2176
- 'faIcon' => 'fas fa-link',
2177
- 'name' => 'user_nicename',
2178
- 'canBeInactive' => array(
2179
- 'register',
2180
- 'account',
2181
- 'profile',
2182
- 'search'
2183
- ),
2184
- 'canEdit' => $usergroupids_can_edit_fields,
2185
- 'canView' => $usergroupids,
2186
- 'can' => '',
2187
- 'isSearchable' => 1
2188
- );
2189
2190
- $this->fields['title'] = array(
2191
- 'fieldKey' => 'title',
2192
- 'type' => 'text',
2193
- 'isDefault' => 1,
2194
- 'isRemovable' => 0,
2195
- 'isRequired' => 1,
2196
- 'isEditable' => 1,
2197
- 'label' => wpforo_phrase('Title', false),
2198
- 'title' => wpforo_phrase('Title', false),
2199
- 'placeholder' => wpforo_phrase('Title', false),
2200
- 'minLength' => 0,
2201
- 'maxLength' => 0,
2202
- 'faIcon' => 'fas fa-user',
2203
- 'name' => 'title',
2204
- 'canBeInactive' => array(
2205
- 'register',
2206
- 'account',
2207
- 'profile',
2208
- 'search'
2209
- ),
2210
- 'canEdit' => $usergroupids_can_edit_fields,
2211
- 'canView' => WPF()->perm->usergroups_can('vmt'),
2212
- 'can' => 'vmt',
2213
- 'isSearchable' => 1
2214
- );
2215
2216
- $this->fields['groupid'] = array(
2217
- 'fieldKey' => 'groupid',
2218
- 'type' => 'usergroup',
2219
- 'isDefault' => 1,
2220
- 'isRemovable' => 0,
2221
- 'isRequired' => 1,
2222
- 'isEditable' => 1,
2223
- 'label' => wpforo_phrase('User Group', false),
2224
- 'title' => wpforo_phrase('User Group', false),
2225
- 'placeholder' => wpforo_phrase('User Group', false),
2226
- 'faIcon' => 'fas fa-users',
2227
- 'name' => 'groupid',
2228
- 'allowedGroupIds' => array(3, 5),
2229
- 'canBeInactive' => array(
2230
- 'register',
2231
- 'account',
2232
- 'profile',
2233
- 'search'
2234
- ),
2235
- 'canEdit' => $usergroupids_can_edit_fields,
2236
- 'canView' => $usergroupids,
2237
- 'can' => '',
2238
- 'isSearchable' => 1
2239
- );
2240
2241
- $this->fields['secondary_groups'] = array(
2242
- 'fieldKey' => 'secondary_groups',
2243
- 'type' => 'checkbox',
2244
- 'isWrapItem' => 1,
2245
- 'isDefault' => 1,
2246
- 'isRemovable' => 0,
2247
- 'isRequired' => 0,
2248
- 'isEditable' => 0,
2249
- 'label' => wpforo_phrase('User Groups Secondary', false),
2250
- 'title' => wpforo_phrase('User Groups Secondary', false),
2251
- 'placeholder' => '',
2252
- 'faIcon' => '',
2253
- 'values' => $secondary_groups,
2254
- 'name' => 'secondary_groups',
2255
- 'allowedGroupIds' => array(3, 5),
2256
- 'canBeInactive' => array(
2257
- 'register',
2258
- 'account',
2259
- 'profile',
2260
- 'search'
2261
- ),
2262
- 'canEdit' => $usergroupids_can_edit_fields,
2263
- 'canView' => $usergroupids,
2264
- 'can' => '',
2265
- 'isSearchable' => 1
2266
- );
2267
2268
- $this->fields['avatar'] = array(
2269
- 'fieldKey' => 'avatar',
2270
- 'type' => 'avatar',
2271
- 'isDefault' => 1,
2272
- 'isRemovable' => 0,
2273
- 'isRequired' => 0,
2274
- 'isEditable' => 1,
2275
- 'label' => wpforo_phrase('Avatar', false),
2276
- 'title' => wpforo_phrase('Avatar', false),
2277
- 'placeholder' => wpforo_phrase('Avatar', false),
2278
- 'name' => 'avatar',
2279
- 'canBeInactive' => array(
2280
- 'register',
2281
- 'account',
2282
- 'profile',
2283
- 'search'
2284
- ),
2285
- 'canEdit' => $usergroupids_can_edit_fields,
2286
- 'canView' => WPF()->perm->usergroups_can('va'),
2287
- 'can' => 'va',
2288
- 'isSearchable' => 0
2289
- );
2290
2291
- $this->fields['site'] = array(
2292
- 'fieldKey' => 'site',
2293
- 'type' => 'url',
2294
- 'isDefault' => 1,
2295
- 'isRemovable' => 0,
2296
- 'isRequired' => 0,
2297
- 'isEditable' => 1,
2298
- 'label' => wpforo_phrase('Website', false),
2299
- 'title' => wpforo_phrase('Website', false),
2300
- 'placeholder' => wpforo_phrase('Website', false),
2301
- 'faIcon' => 'fas fa-sitemap',
2302
- 'name' => 'site',
2303
- 'canBeInactive' => array(
2304
- 'register',
2305
- 'account',
2306
- 'profile',
2307
- 'search'
2308
- ),
2309
- 'canEdit' => $usergroupids_can_edit_fields,
2310
- 'canView' => WPF()->perm->usergroups_can('vmw'),
2311
- 'can' => 'vmw',
2312
- 'isSearchable' => 1
2313
- );
2314
2315
- $this->fields['facebook'] = array(
2316
- 'fieldKey' => 'facebook',
2317
- 'type' => 'url',
2318
- 'isDefault' => 1,
2319
- 'isRemovable' => 0,
2320
- 'isRequired' => 0,
2321
- 'isEditable' => 1,
2322
- 'label' => wpforo_phrase('Facebook', false),
2323
- 'title' => wpforo_phrase('Facebook', false),
2324
- 'placeholder' => wpforo_phrase('Facebook', false),
2325
- 'faIcon' => 'fab fa-facebook',
2326
- 'name' => 'facebook',
2327
- 'canBeInactive' => array(
2328
- 'register',
2329
- 'account',
2330
- 'profile',
2331
- 'search'
2332
- ),
2333
- 'canEdit' => $usergroupids_can_edit_fields,
2334
- 'canView' => $usergroupids_can_view_social_net,
2335
- 'can' => 'vmsn',
2336
- 'isSearchable' => 1
2337
- );
2338
2339
- $this->fields['twitter'] = array(
2340
- 'fieldKey' => 'twitter',
2341
- 'type' => 'url',
2342
- 'isDefault' => 1,
2343
- 'isRemovable' => 0,
2344
- 'isRequired' => 0,
2345
- 'isEditable' => 1,
2346
- 'label' => wpforo_phrase('Twitter', false),
2347
- 'title' => wpforo_phrase('Twitter', false),
2348
- 'placeholder' => wpforo_phrase('Twitter', false),
2349
- 'faIcon' => 'fab fa-twitter-square',
2350
- 'name' => 'twitter',
2351
- 'canBeInactive' => array(
2352
- 'register',
2353
- 'account',
2354
- 'profile',
2355
- 'search'
2356
- ),
2357
- 'canEdit' => $usergroupids_can_edit_fields,
2358
- 'canView' => $usergroupids_can_view_social_net,
2359
- 'can' => 'vmsn',
2360
- 'isSearchable' => 1
2361
- );
2362
2363
- $this->fields['gtalk'] = array(
2364
- 'fieldKey' => 'gtalk',
2365
- 'type' => 'url',
2366
- 'isDefault' => 1,
2367
- 'isRemovable' => 0,
2368
- 'isRequired' => 0,
2369
- 'isEditable' => 1,
2370
- 'label' => wpforo_phrase('Google+', false),
2371
- 'title' => wpforo_phrase('Google+', false),
2372
- 'placeholder' => wpforo_phrase('Google+', false),
2373
- 'faIcon' => 'fab fa-google-plus-square',
2374
- 'name' => 'gtalk',
2375
- 'canBeInactive' => array(
2376
- 'register',
2377
- 'account',
2378
- 'profile',
2379
- 'search'
2380
- ),
2381
- 'canEdit' => $usergroupids_can_edit_fields,
2382
- 'canView' => $usergroupids_can_view_social_net,
2383
- 'can' => 'vmsn',
2384
- 'isSearchable' => 1
2385
- );
2386
2387
- $this->fields['yahoo'] = array(
2388
- 'fieldKey' => 'yahoo',
2389
- 'type' => 'text',
2390
- 'isDefault' => 1,
2391
- 'isRemovable' => 0,
2392
- 'isRequired' => 0,
2393
- 'isEditable' => 1,
2394
- 'label' => wpforo_phrase('Yahoo', false),
2395
- 'title' => wpforo_phrase('Yahoo', false),
2396
- 'placeholder' => wpforo_phrase('Yahoo', false),
2397
- 'faIcon' => 'fab fa-yahoo',
2398
- 'name' => 'yahoo',
2399
- 'canBeInactive' => array(
2400
- 'register',
2401
- 'account',
2402
- 'profile',
2403
- 'search'
2404
- ),
2405
- 'canEdit' => $usergroupids_can_edit_fields,
2406
- 'canView' => $usergroupids_can_view_social_net,
2407
- 'can' => 'vmsn',
2408
- 'isSearchable' => 1
2409
- );
2410
2411
- $this->fields['aim']= array(
2412
- 'fieldKey' => 'aim',
2413
- 'type' => 'text',
2414
- 'isDefault' => 1,
2415
- 'isRemovable' => 0,
2416
- 'isRequired' => 0,
2417
- 'isEditable' => 1,
2418
- 'label' => wpforo_phrase('AOL IM', false),
2419
- 'title' => wpforo_phrase('AOL IM', false),
2420
- 'placeholder' => wpforo_phrase('AOL IM', false),
2421
- 'faIcon' => 'fas fa-share-alt',
2422
- 'name' => 'aim',
2423
- 'canBeInactive' => array(
2424
- 'register',
2425
- 'account',
2426
- 'profile',
2427
- 'search'
2428
- ),
2429
- 'canEdit' => $usergroupids_can_edit_fields,
2430
- 'canView' => $usergroupids_can_view_social_net,
2431
- 'can' => 'vmsn',
2432
- 'isSearchable' => 1
2433
- );
2434
2435
- $this->fields['icq'] = array(
2436
- 'fieldKey' => 'icq',
2437
- 'type' => 'text',
2438
- 'isDefault' => 1,
2439
- 'isRemovable' => 0,
2440
- 'isRequired' => 0,
2441
- 'isEditable' => 1,
2442
- 'label' => wpforo_phrase('ICQ', false),
2443
- 'title' => wpforo_phrase('ICQ', false),
2444
- 'placeholder' => wpforo_phrase('ICQ', false),
2445
- 'faIcon' => 'fas fa-share-alt',
2446
- 'name' => 'icq',
2447
- 'canBeInactive' => array(
2448
- 'register',
2449
- 'account',
2450
- 'profile',
2451
- 'search'
2452
- ),
2453
- 'canEdit' => $usergroupids_can_edit_fields,
2454
- 'canView' => $usergroupids_can_view_social_net,
2455
- 'can' => 'vmsn',
2456
- 'isSearchable' => 1
2457
- );
2458
2459
- $this->fields['msn'] = array(
2460
- 'fieldKey' => 'msn',
2461
- 'type' => 'text',
2462
- 'isDefault' => 1,
2463
- 'isRemovable' => 0,
2464
- 'isRequired' => 0,
2465
- 'isEditable' => 1,
2466
- 'label' => wpforo_phrase('MSN', false),
2467
- 'title' => wpforo_phrase('MSN', false),
2468
- 'placeholder' => wpforo_phrase('MSN', false),
2469
- 'faIcon' => 'fas fa-share-alt',
2470
- 'name' => 'msn',
2471
- 'canBeInactive' => array(
2472
- 'register',
2473
- 'account',
2474
- 'profile',
2475
- 'search'
2476
- ),
2477
- 'canEdit' => $usergroupids_can_edit_fields,
2478
- 'canView' => $usergroupids_can_view_social_net,
2479
- 'can' => 'vmsn',
2480
- 'isSearchable' => 1
2481
- );
2482
2483
- $this->fields['skype'] = array(
2484
- 'fieldKey' => 'skype',
2485
- 'type' => 'text',
2486
- 'isDefault' => 1,
2487
- 'isRemovable' => 0,
2488
- 'isRequired' => 0,
2489
- 'isEditable' => 1,
2490
- 'label' => wpforo_phrase('Skype', false),
2491
- 'title' => wpforo_phrase('Skype', false),
2492
- 'placeholder' => wpforo_phrase('Skype', false),
2493
- 'faIcon' => 'fab fa-skype',
2494
- 'name' => 'skype',
2495
- 'canBeInactive' => array(
2496
- 'register',
2497
- 'account',
2498
- 'profile',
2499
- 'search'
2500
- ),
2501
- 'canEdit' => $usergroupids_can_edit_fields,
2502
- 'canView' => $usergroupids_can_view_social_net,
2503
- 'can' => 'vmsn',
2504
- 'isSearchable' => 1
2505
- );
2506
2507
- $this->fields['location'] = array(
2508
- 'fieldKey' => 'location',
2509
- 'type' => 'select',
2510
- 'isDefault' => 1,
2511
- 'isRemovable' => 0,
2512
- 'isRequired' => 0,
2513
- 'isEditable' => 1,
2514
- 'label' => wpforo_phrase('Location', false),
2515
- 'title' => wpforo_phrase('Location', false),
2516
- 'placeholder' => wpforo_phrase('Location', false),
2517
- 'faIcon' => 'fas fa-globe',
2518
- 'values' => $this->countries,
2519
- 'name' => 'location',
2520
- 'canBeInactive' => array(
2521
- 'register',
2522
- 'account',
2523
- 'profile',
2524
- 'search'
2525
- ),
2526
- 'canEdit' => $usergroupids_can_edit_fields,
2527
- 'canView' => WPF()->perm->usergroups_can('vml'),
2528
- 'can' => 'vml',
2529
- 'isSearchable' => 1
2530
- );
2531
2532
- $this->fields['timezone'] = array(
2533
- 'fieldKey' => 'timezone',
2534
- 'type' => 'select',
2535
- 'isDefault' => 1,
2536
- 'isRemovable' => 0,
2537
- 'isRequired' => 0,
2538
- 'isEditable' => 1,
2539
- 'label' => wpforo_phrase('Timezone', false),
2540
- 'title' => wpforo_phrase('Timezone', false),
2541
- 'placeholder' => wpforo_phrase('Timezone', false),
2542
- 'faIcon' => 'fas fa-globe',
2543
- 'values' => $this->timezones,
2544
- 'name' => 'timezone',
2545
- 'canBeInactive' => array(
2546
- 'register',
2547
- 'account',
2548
- 'profile',
2549
- 'search'
2550
- ),
2551
- 'canEdit' => $usergroupids_can_edit_fields,
2552
- 'canView' => $usergroupids,
2553
- 'can' => '',
2554
- 'isSearchable' => 1
2555
- );
2556
2557
- $this->fields['occupation'] = array(
2558
- 'fieldKey' => 'occupation',
2559
- 'type' => 'text',
2560
- 'isDefault' => 1,
2561
- 'isRemovable' => 0,
2562
- 'isRequired' => 0,
2563
- 'isEditable' => 1,
2564
- 'label' => wpforo_phrase('Occupation', false),
2565
- 'title' => wpforo_phrase('Occupation', false),
2566
- 'placeholder' => wpforo_phrase('Occupation', false),
2567
- 'faIcon' => 'fas fa-address-card',
2568
- 'name' => 'occupation',
2569
- 'canBeInactive' => array(
2570
- 'register',
2571
- 'account',
2572
- 'profile',
2573
- 'search'
2574
- ),
2575
- 'canEdit' => $usergroupids_can_edit_fields,
2576
- 'canView' => WPF()->perm->usergroups_can('vmo'),
2577
- 'can' => 'vmo',
2578
- 'isSearchable' => 1
2579
- );
2580
2581
- $this->fields['signature'] = array(
2582
- 'fieldKey' => 'signature',
2583
- 'type' => 'textarea',
2584
- 'isDefault' => 1,
2585
- 'isRemovable' => 0,
2586
- 'isRequired' => 0,
2587
- 'isEditable' => 1,
2588
- 'label' => wpforo_phrase('Signature', false),
2589
- 'title' => wpforo_phrase('Signature', false),
2590
- 'placeholder' => wpforo_phrase('Signature', false),
2591
- 'faIcon' => 'fas fa-address-card',
2592
- 'name' => 'signature',
2593
- 'canBeInactive' => array(
2594
- 'register',
2595
- 'account',
2596
- 'profile',
2597
- 'search'
2598
- ),
2599
- 'canEdit' => $usergroupids_can_edit_fields,
2600
- 'canView' => WPF()->perm->usergroups_can('vms'),
2601
- 'can' => 'vms',
2602
- 'isSearchable' => 1
2603
- );
2604
2605
- $this->fields['about'] = array(
2606
- 'fieldKey' => 'about',
2607
- 'type' => 'textarea',
2608
- 'isDefault' => 1,
2609
- 'isRemovable' => 0,
2610
- 'isRequired' => 0,
2611
- 'isEditable' => 1,
2612
- 'label' => wpforo_phrase('About Me', false),
2613
- 'title' => wpforo_phrase('About Me', false),
2614
- 'placeholder' => wpforo_phrase('About Me', false),
2615
- 'faIcon' => 'fas fa-address-card',
2616
- 'name' => 'about',
2617
- 'canBeInactive' => array(
2618
- 'register',
2619
- 'account',
2620
- 'profile',
2621
- 'search'
2622
- ),
2623
- 'canEdit' => $usergroupids_can_edit_fields,
2624
- 'canView' => WPF()->perm->usergroups_can('vmam'),
2625
- 'can' => 'vmam',
2626
- 'isSearchable' => 1
2627
- );
2628
2629
- $this->fields['html_soc_net'] = array(
2630
- 'fieldKey' => 'html_soc_net',
2631
- 'type' => 'html',
2632
- 'isDefault' => 1,
2633
- 'isRemovable' => 0,
2634
- 'isRequired' => 0,
2635
- 'isEditable' => 1,
2636
- 'label' => wpforo_phrase('Social Networks', false),
2637
- 'title' => wpforo_phrase('Social Networks', false),
2638
- 'placeholder' => wpforo_phrase('Social Networks', false),
2639
- 'description' => wpforo_phrase('Social Networks', false),
2640
- 'html' => '<div class="wpf-label">' . wpforo_phrase('Social Networks', false) . '</div>',
2641
- 'name' => 'html_soc_net',
2642
- 'canBeInactive' => array(
2643
- 'register',
2644
- 'account',
2645
- 'profile',
2646
- 'search'
2647
- ),
2648
- 'canEdit' => $usergroupids_can_edit_fields,
2649
- 'canView' => $usergroupids_can_view_social_net,
2650
- 'can' => 'vmsn',
2651
- 'isSearchable' => 0
2652
- );
2653
2654
- $this->fields = apply_filters('wpforo_member_after_init_fields', $this->fields);
2655
- }
2656
2657
private function init_countries(){
2658
$this->countries = array( "Afghanistan","Ă…land Islands","Albania","Algeria","American Samoa","Andorra","Angola","Anguilla","Antarctica",
@@ -2728,166 +2606,198 @@ class wpForoMember{
2728
2729
public function get_fields($only_defaults = false){
2730
$this->init_fields();
2731
- $fields = $this->fields;
2732
2733
- if(!$only_defaults) $fields = apply_filters('wpforo_get_fields', $fields);
2734
- return $fields;
2735
}
2736
2737
- public function get_register_fields($only_defaults = false){
2738
- $this->init_fields();
2739
- $password = false;
2740
- $regform = array(
2741
- $this->fields['user_login'],
2742
- $this->fields['user_email']
2743
- );
2744
- if( !wpforo_feature('user-register-email-confirm') ) $regform[] = $this->fields['user_pass'];
2745
- $fields = array(
2746
- array(
2747
- $regform
2748
- )
2749
- );
2750
- if(!$only_defaults) {
2751
- $fields = apply_filters('wpforo_get_register_fields', $fields);
2752
- foreach( $fields as $kr => $row ){
2753
- foreach( $row as $kc => $cols ){
2754
- foreach( $cols as $kf => $field ){
2755
- if( 'user_pass' == $field['name'] ){
2756
- if( wpforo_feature('user-register-email-confirm') ){
2757
- unset( $fields[$kr][$kc][$kf] );
2758
- $password = false;
2759
- } else {
2760
- $password = true;
2761
- }
2762
- }
2763
- }
2764
- }
2765
- }
2766
- if( !wpforo_feature('user-register-email-confirm') && !$password ){
2767
- $fields[$kr][$kc][] = $this->fields['user_pass'];
2768
- }
2769
- }
2770
return $fields;
2771
}
2772
2773
- public function get_account_fields($only_defaults = false){
2774
- $this->init_fields();
2775
2776
$fields = array(
2777
array(
2778
array(
2779
- $this->fields['user_login'],
2780
- $this->fields['display_name'],
2781
- $this->fields['user_nicename'],
2782
- $this->fields['user_email'],
2783
- $this->fields['title'],
2784
- $this->fields['groupid'],
2785
- $this->fields['secondary_groups'],
2786
- $this->fields['avatar'],
2787
- $this->fields['about'],
2788
- $this->fields['site'],
2789
- $this->fields['occupation'],
2790
- $this->fields['signature']
2791
)
2792
),
2793
array(
2794
array(
2795
- $this->fields['html_soc_net']
2796
),
2797
array(
2798
- $this->fields['facebook'],
2799
- $this->fields['gtalk'],
2800
- $this->fields['aim'],
2801
- $this->fields['msn']
2802
),
2803
array(
2804
- $this->fields['twitter'],
2805
- $this->fields['yahoo'],
2806
- $this->fields['icq'],
2807
- $this->fields['skype']
2808
)
2809
),
2810
array(
2811
array(
2812
- $this->fields['location'],
2813
- $this->fields['timezone'],
2814
- $this->fields['user_pass']
2815
)
2816
)
2817
);
2818
-
2819
if(!$only_defaults) $fields = apply_filters('wpforo_get_account_fields', $fields);
2820
return $fields;
2821
}
2822
2823
- public function get_profile_fields($only_defaults = false){
2824
- $this->init_fields();
2825
2826
$fields = array(
2827
array(
2828
array(
2829
- $this->fields['about'],
2830
- $this->fields['site'],
2831
)
2832
),
2833
array(
2834
array(
2835
- $this->fields['location'],
2836
- $this->fields['timezone'],
2837
- $this->fields['occupation'],
2838
- $this->fields['signature']
2839
)
2840
),
2841
array(
2842
array(
2843
- $this->fields['html_soc_net']
2844
),
2845
),
2846
array(
2847
array(
2848
- $this->fields['facebook'],
2849
- $this->fields['gtalk'],
2850
- $this->fields['aim'],
2851
- $this->fields['msn'],
2852
),
2853
array(
2854
- $this->fields['twitter'],
2855
- $this->fields['yahoo'],
2856
- $this->fields['icq'],
2857
- $this->fields['skype']
2858
)
2859
),
2860
);
2861
-
2862
if(!$only_defaults) $fields = apply_filters('wpforo_get_profile_fields', $fields);
2863
- return $fields;
2864
}
2865
2866
- public function get_search_fields($only_defaults = false){
2867
- $this->init_fields();
2868
-
2869
- $fields = array(
2870
- array(
2871
- array(
2872
- $this->fields['display_name'],
2873
- $this->fields['user_nicename'],
2874
- )
2875
- )
2876
- );
2877
2878
if(!$only_defaults) $fields = apply_filters('wpforo_get_search_fields', $fields);
2879
2880
foreach ($fields as $row_key => $row){
2881
foreach ($row as $col_key => $col){
2882
foreach ($col as $field_key => $field){
2883
- $fields[$row_key][$col_key][$field_key]['isRequired'] = 0;
2884
- $fields[$row_key][$col_key][$field_key]['class'] = 'wpf-member-search-field';
2885
- if( $field['type'] == 'text' || $field['type'] == 'textarea' || $field['type'] == 'email' || $field['type'] == 'url' )
2886
- $fields[$row_key][$col_key][$field_key]['type'] = 'search';
2887
}
2888
}
2889
}
2890
-
2891
return $fields;
2892
}
2893
@@ -2962,14 +2872,55 @@ class wpForoMember{
2962
}
2963
2964
public function set_usergroup($userid, $groupid){
2965
if($userid && $groupid){
2966
- WPF()->db->query( "UPDATE `" . WPF()->tables->profiles . "` SET `groupid` = " . intval($groupid) . " WHERE `userid` = " . wpforo_bigintval($userid) );
2967
- $this->reset($userid);
2968
}
2969
}
2970
2971
- public function set_usergroups_secondary($userid, $group_ids = array()){
2972
- //TODO: set_usergroups_secondary() method condition
2973
}
2974
2975
public function after_register_new_user($userid){
92
$sql = WPF()->db->prepare(
93
$sql,
94
$userid,
95
+ ( isset($title) && $title ? $title : $this->options['default_title'] ),
96
sanitize_user($username),
97
intval((isset($groupid) && $groupid ? $groupid : WPF()->usergroup->default_groupid)),
98
(isset($site) ? sanitize_text_field($site) : '' ),
121
//-- START -- copied from update code
122
//Define $user
123
$user = $user_fields;
124
125
//Define $userid
126
$userid = intval( wpfval($user, 'userid') );
127
128
//Check custom fields and merge to $user array
129
+ if( wpfval($data, 'data') && is_array($data['data']) && !empty($data['data']) ){
130
+ $custom_fields = $data['data'];
131
$user = array_merge( $custom_fields, $user );
132
}
133
134
//Check file uploading custom fields and merge to $user array
135
+ $file_data = isset($_FILES['data']['name']) && $_FILES['data']['name'] && is_array($_FILES['data']['name']) ? array_filter($_FILES['data']['name']) : array();
136
$file_fields = WPF()->form->prepare_file_args( $file_data, $userid );
137
if( wpfval( $file_fields, 'fields') ) {
138
$user = array_merge( $file_fields['fields'], $user );
280
/**
281
* @deprecated since 1.5.0
282
* @deprecated No longer used by core and not recommended.
283
+ * @deprecated Use $this->update()
284
*/
285
function edit( $args = array() ){
286
if( empty($args) && empty($_REQUEST['member']) ) return FALSE;
373
/**
374
* @deprecated since 1.5.0
375
* @deprecated No longer used by core and not recommended.
376
+ * @deprecated Use $this->update()
377
+ * @deprecated Or use $this->update_profile_field() for one field update
378
*/
379
function edit_profile($args){
380
if(empty($args)) return FALSE;
511
*
512
* $data['member']['userid'] or $data['userid'] is required
513
*
514
+ * @param string|array $type User data update types (comma separated)
515
* $type = 'full' user fields, profile fields, custom fields
516
* $type = 'user' only user fields (wp_users table)
517
* $type = 'profile' only profile fields (wp_wpforo_profiles table)
523
* @return false|array wpForo User array
524
*/
525
public function update( $data, $type = 'full', $check_permissions = true ){
526
+ $type = (array) $type;
527
+
528
+ switch (WPF()->current_object['template']){
529
+ case 'register':
530
+ $form = 'wpfreg';
531
+ $form_fields = $this->get_register_fields();
532
+ break;
533
+ default:
534
+ $form = 'member';
535
+ $form_fields = $this->get_account_fields();
536
+ break;
537
+ }
538
if( !$form_fields ){ WPF()->notice->add( 'Form template not found', 'error'); return false; }
539
540
if( !wpfkey($data, $form) ){
541
+ if( in_array('custom_fields', $type) && count($type) === 1 ){
542
+ if( !wpfval($data, 'data') ){
543
+ $data[ 'data' ] = $data;
544
+ if( wpfkey($data, 'data', 'userid') ) unset($data[ 'data' ]['userid']);
545
}
546
} else {
547
$data[ $form ] = $data;
548
}
549
}
550
+ if( wpfval($data, 'userid') && !wpfval($data, $form, 'userid') ) $data[ $form ]['userid'] = $data['userid'];
551
552
if( wpfval($data, $form, 'userid') ){
553
$result_user = true;
554
$result_fields = true;
555
$result_profile = true;
565
if( $check_permissions ) WPF()->perm->can_edit_user( $userid );
566
567
//Check custom fields and merge to $user array
568
+ if( wpfkey($data, 'data') && is_array($data['data']) && !empty($data['data']) ){
569
+ $custom_fields = $data['data'];
570
$user = array_merge( $custom_fields, $user );
571
}
572
573
//Check file uploading custom fields and merge to $user array
574
+ $file_data = isset($_FILES['data']['name']) && $_FILES['data']['name'] && is_array($_FILES['data']['name']) ? array_filter($_FILES['data']['name']) : array();
575
$file_fields = WPF()->form->prepare_file_args( $file_data, $userid );
576
if( wpfval( $file_fields, 'fields') ) {
577
$user = array_merge( $file_fields['fields'], $user );
622
$result_password = false;
623
}
624
if( $result_password && wpfval($user, 'old_pass') && wpfval($user, 'user_pass1') ){
625
+ $result_password = $this->change_password( $user['old_pass'], $user['user_pass1'], $userid );
626
}
627
628
//Upload avatar
629
+ if( wpfval($user, 'avatar_type') === 'custom' ){
630
+ $this->upload_avatar($userid);
631
}
632
633
//Update Custom Fields
802
$profile_fields['avatar'] = '';
803
$profile_fields_types[] = '%s';
804
}
805
+ if( wpfkey($data, 'secondary_groups') ){
806
+ $data['secondary_groups'] = array_filter( array_map('intval', (array) $data['secondary_groups']) );
807
+ $profile_fields['secondary_groups'] = implode( ',', $data['secondary_groups'] );
808
+ $profile_fields_types[] = '%s';
809
}
810
if( wpfkey($data, 'rank') ){
811
$profile_fields['rank'] = $data['rank'];
966
967
public function upload_files( $file_fields ){
968
if ( !empty( $file_fields ) ) {
969
foreach( $file_fields as $field_name => $file_path ) {
970
+ if( wpfval( $_FILES, 'data', 'tmp_name', $field_name ) &&
971
+ !move_uploaded_file( $_FILES[ 'data' ]['tmp_name'][$field_name], $file_path )
972
) {
973
WPF()->notice->add('Sorry, there was an error uploading attached file', 'error');
974
}
1037
1038
public function synchronize_user($userid, $roles_usergroups = array()){
1039
$groupid = false;
1040
+ if(!$userid) return false;
1041
$user = get_userdata($userid);
1042
1043
//Don't synchronize User Roles with Usergroups if the option is disabled
1066
$insert_groupid = ( isset($_POST['wpforo_usergroup']) && !wpforo_feature('role-synch') ) ? intval($_POST['wpforo_usergroup']) : $groupid;
1067
$insert_timezone = (isset($_POST['wpforo_usertimezone'])) ? sanitize_text_field($_POST['wpforo_usertimezone']) : '';
1068
$about = get_user_meta( $userid, 'description', true );
1069
+ $return = $this->add_profile(
1070
array( 'userid' => wpforo_bigintval($userid),
1071
'username' => sanitize_user($user->user_login),
1072
'groupid' => intval($insert_groupid),
1074
'timezone' => sanitize_text_field($insert_timezone),
1075
'about' => stripslashes( wpforo_kses(trim($about), 'user_description') ),
1076
'last_login' => sanitize_text_field($user->user_registered) ) );
1077
+
1078
+ if( $return !== false && ($secondary_groups = wpfval($_POST, 'wpforo_secondary_usergroup')) ){
1079
+ $this->set_usergroups_secondary($userid, $secondary_groups);
1080
+ }
1081
+ return $return;
1082
}
1083
1084
public function synchronize_users($limit = NULL){
1165
1166
if(!empty($member)) {
1167
$member['profile_url'] = $this->profile_url( $member );
1168
+ if( !wpfval($member, 'stat') ) $member['stat'] = $this->get_stat( $member, false, true );
1169
+ $fields = wpfval($member, 'fields');
1170
+ if( is_string($fields) && $fields ) $member = array_merge((array) json_decode($fields, true), $member);
1171
if( $do_db_cache ){
1172
if(!$user_meta_obj) update_user_meta( $userid, '_wpf_member_obj', $member );
1173
}
1352
1353
if( !($reassign = intval($reassign)) ){
1354
if( $postids = WPF()->db->get_col( WPF()->db->prepare( "SELECT `postid` FROM `".WPF()->tables->posts."` WHERE userid = %d", $userid ) ) ){
1355
+ foreach( $postids as $postid ) WPF()->post->delete($postid, true, true, $exclude, false);
1356
}
1357
1358
if( $topicids = WPF()->db->get_col( WPF()->db->prepare( "SELECT `topicid` FROM `".WPF()->tables->topics."` WHERE userid = %d", $userid ) ) ){
1453
$cache = WPF()->cache->on('memory_cashe');
1454
1455
if($cache && isset(self::$cache['avatar'][$userid])){
1456
+ if( wpfval(self::$cache['avatar'][$userid], 'attr') == $attr && wpfval(self::$cache['avatar'][$userid], 'size') == $size){
1457
if(isset(self::$cache['avatar'][$userid]['img'])){
1458
return self::$cache['avatar'][$userid]['img'];
1459
}
1460
}
1461
}
1462
+ $img = $this->get_avatar_html($this->get_avatar_url($userid), $userid, $attr, $size );
1463
if($cache){
1464
self::$cache['avatar'][$userid]['attr'] = $attr;
1465
self::$cache['avatar'][$userid]['size'] = $size;
1485
return $avatar_url;
1486
}
1487
1488
+ public function get_avatar_html($url, $userid = 0, $attr = '', $size = '' ) {
1489
+ if($url && wpforo_feature('custom-avatars')){
1490
+ $attr = ($attr ? $attr : 'height="96" width="96"');
1491
+ $img = '<img class="avatar" src="'.esc_url($url).'" '. $attr .' />';
1492
+ }else{
1493
+ $img = ($size) ? get_avatar($userid, $size) : get_avatar($userid);
1494
+ if($attr) $img = str_replace('<img', '<img ' . $attr, $img);
1495
+ }
1496
+ return $img;
1497
+ }
1498
+
1499
public function get_topics_count( $userid ){
1500
$count = WPF()->db->get_var("SELECT count(topicid) FROM `".WPF()->tables->topics."` WHERE `userid` = ".intval($userid));
1501
return $count;
1545
1546
public function get_profile_url( $arg, $template = 'profile' ){
1547
if(!$arg) return wpforo_home_url();
1548
+ $template_slug = wpforo_get_template_slug($template);
1549
$userid = intval( basename($arg) );
1550
$member_args = ( $userid ? $userid : array( 'user_nicename' => basename($arg) ) );
1551
$user = $this->get_member( $member_args );
1552
if(empty($user)) return wpforo_home_url();
1553
+ $user_slug = ( wpfo($this->options['url_structure'], false) === 'id' ? $user['ID'] : $user['user_nicename'] );
1554
$profile_url = wpforo_home_url("$template_slug/$user_slug");
1555
return apply_filters('wpforo_member_profile_url', $profile_url, $user, $template);
1556
}
1557
1558
public function profile_url( $member = array(), $template = 'profile' ){
1559
+ $template_slug = wpforo_get_template_slug($template);
1560
if(isset($member['ID']) || isset($member['user_nicename'])){
1561
+ $user_slug = ( wpfo($this->options['url_structure'], false) === 'id' ? $member['ID'] : $member['user_nicename'] );
1562
$profile_url = wpforo_home_url("$template_slug/$user_slug");
1563
$profile_url = apply_filters( 'wpforo_profile_url', $profile_url, $member, $template );
1564
}
1662
}
1663
1664
public function is_online( $userid, $duration = NULL ){
1665
+ if(!$duration) $duration = $this->options['online_status_timeout'];
1666
1667
$cache = WPF()->cache->on('memory_cashe');
1668
1710
}
1711
1712
public function online_members_count( $duration = NULL ){
1713
+ if(!$duration) $duration = $this->options['online_status_timeout'];
1714
$current_time = current_time( 'timestamp', 1 );
1715
$online_timeframe = $current_time - $duration;
1716
$online = WPF()->db->get_var( "SELECT COUNT(DISTINCT `userid`, `ip`) AS total FROM `".WPF()->tables->visits."` WHERE `time` > " . intval($online_timeframe) );
1719
}
1720
1721
public function get_online_members( $count = 1, $groupids = array(), $duration = NULL ){
1722
+ if(!$duration) $duration = $this->options['online_status_timeout'];
1723
$current_time = current_time( 'timestamp', 1 );
1724