-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserregistration.php
More file actions
4089 lines (3075 loc) · 188 KB
/
userregistration.php
File metadata and controls
4089 lines (3075 loc) · 188 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
Plugin Name: Gravity Forms User Registration Add-On
Plugin URI: http://www.gravityforms.com
Description: Allows WordPress users to be automatically created upon submitting a Gravity Form
Version: 2.1
Author: rocketgenius
Author URI: http://www.rocketgenius.com
------------------------------------------------------------------------
Copyright 2009 rocketgenius
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
add_action('init', array('GFUser', 'init'), 9);
add_action('wp', array('GFUser', 'maybe_activate_user'));
register_activation_hook( __FILE__, array("GFUser", "add_permissions") );
class GFUser {
private static $path = "gravityformsuserregistration/userregistration.php";
private static $url = "http://www.gravityforms.com";
private static $slug = "gravityformsuserregistration";
private static $version = "2.1";
private static $min_gravityforms_version = "1.7";
private static $supported_fields = array( "checkbox", "radio", "select", "text", "website", "textarea", "email", "hidden", "number", "phone", "multiselect", "post_title",
"post_tags", "post_custom_field", "post_content", "post_excerpt" );
//Plugin starting point. Will load appropriate files
public static function init(){
//supports logging
add_filter("gform_logging_supported", array("GFUser", "set_logging_supported"));
//loading translations
load_plugin_textdomain('gravityformsuserregistration', FALSE, '/gravityformsuserregistration/languages' );
if(basename($_SERVER['PHP_SELF']) == "plugins.php") {
add_action('after_plugin_row_' . self::$path, array('GFUser', 'plugin_row') );
}
if(!self::is_gravityforms_supported())
return;
if(is_admin()){
//runs the setup when version changes
self::setup();
// automatic upgrade hooks
add_filter("transient_update_plugins", array('GFUser', 'check_update'));
add_filter("site_transient_update_plugins", array('GFUser', 'check_update'));
add_action('install_plugins_pre_plugin-information', array('GFUser', 'display_changelog'));
add_action('gform_after_check_update', array("GFUser", 'flush_version_info'));
// paypal plugin integration hooks
add_action("gform_paypal_add_option_group", array("GFUser", "add_paypal_user_registration_options"), 10, 2);
add_filter("gform_paypal_save_config", array("GFUser", "save_paypal_user_config"));
// integrating with Members plugin
if(function_exists('members_get_capabilities'))
add_filter('members_get_capabilities', array("GFUser", "members_get_capabilities"));
// creates the subnav left menu
add_filter("gform_addon_navigation", array('GFUser', 'create_menu'));
// activate password field
add_filter("gform_enable_password_field", create_function("", "return true;"));
// process users from unspammed entries
add_action("gform_update_status", array("GFUser", "gf_process_user"), 10, 3);
add_action("gform_paypal_fulfillment", array("GFUser", "add_paypal_user"), 10, 8);
if(self::is_user_registration_page()){
//enqueueing sack for AJAX requests
wp_enqueue_script(array("sack"));
wp_enqueue_script("jquery_json", self::get_base_url() . "/js/jquery.json-1.3.js", array("jquery"), self::$version);
//loading data lib
require_once(self::get_base_path() . "/data.php");
self::include_upgrade_library();
//loading Gravity Forms tooltips
require_once(GFCommon::get_base_path() . "/tooltips.php");
add_filter('gform_tooltips', array('GFUser', 'tooltips'));
}
else if(in_array(RG_CURRENT_PAGE, array("admin-ajax.php"))){
//loading data class
require_once(self::get_base_path() . "/data.php");
add_action('wp_ajax_rg_user_update_feed_active', array('GFUser', 'update_feed_active'));
add_action('wp_ajax_gf_user_select_form', array('GFUser', 'select_form'));
add_action('wp_ajax_gf_user_get_available_forms', array('GFUser', 'get_available_forms'));
add_action('wp_ajax_gf_user_activate', array('GFUser', 'activate_user'));
}
else if(RGForms::get("page") == "gf_settings") {
// add settings page
RGForms::add_settings_page("User Registration", array("GFUser", "settings_page"), self::get_base_url() . "/images/user-registration-icon-32.png");
}
else if(rgget('page') == 'gf_entries') {
// add activate button to entry list page
add_action('gform_entry_info', array('GFUser', 'entry_activation_button'), 10, 2);
}
}
else{
//loading data class
require_once(self::get_base_path() . "/data.php");
// handling post submission
add_action('gform_pre_submission', array( __class__, 'handle_existing_images_submission' ) );
add_action("gform_after_submission", array("GFUser", "gf_create_user"), 10, 2);
add_filter("gform_validation", array("GFUser", "user_registration_validation"));
// add paypal ipn hooks
add_action("gform_paypal_fulfillment", array("GFUser", "add_paypal_user"), 10, 8);
add_action("gform_subscription_canceled", array("GFUser", "downgrade_paypal_user"), 10, 8);
// custom registration form page
add_action('wp_loaded', array('GFUser', 'custom_registration_page'));
// add support for prepopulating update feeds
add_action('gform_pre_render', array('GFUser', 'maybe_prepopulate_form'));
// ManageWP premium update filters
add_filter( 'mwp_premium_update_notification', array('GFUser', 'premium_update_push') );
add_filter( 'mwp_premium_perform_update', array('GFUser', 'premium_update') );
}
// buddypress hooks
if(self::is_bp_active()) {
self::add_buddypress_hooks();
}
// multisite hooks
if(is_multisite()) {
self::add_multisite_hooks();
}
}
public static function update_feed_active(){
check_ajax_referer('rg_user_update_feed_active','rg_user_update_feed_active');
$id = RGForms::post("feed_id");
$feed = GFUserData::get_feed($id);
GFUserData::update_feed($id, $feed["form_id"], RGForms::post("is_active"), $feed["meta"]);
}
//-------------- Automatic upgrade ---------------------------------------
//Integration with ManageWP
public static function premium_update_push( $premium_update ){
if( !function_exists( 'get_plugin_data' ) ) {
include_once( ABSPATH.'wp-admin/includes/plugin.php');
}
self::include_upgrade_library();
$update = RGUserUpgrade::get_version_info(self::$slug, self::get_key(), self::$version);
if( $update["is_valid_key"] == true && version_compare(self::$version, $update["version"], '<') ){
$plugin_data = get_plugin_data( __FILE__ );
$plugin_data['type'] = 'plugin';
$plugin_data['slug'] = self::$path;
$plugin_data['new_version'] = isset($update['version']) ? $update['version'] : false ;
$premium_update[] = $plugin_data;
}
return $premium_update;
}
//Integration with ManageWP
public static function premium_update( $premium_update ){
if( !function_exists( 'get_plugin_data' ) ) {
include_once( ABSPATH.'wp-admin/includes/plugin.php');
}
self::include_upgrade_library();
$update = RGUserUpgrade::get_version_info(self::$slug, self::get_key(), self::$version);
if( $update["is_valid_key"] == true && version_compare(self::$version, $update["version"], '<') ){
$plugin_data = get_plugin_data( __FILE__ );
$plugin_data['slug'] = self::$path;
$plugin_data['type'] = 'plugin';
$plugin_data['url'] = isset($update["url"]) ? $update["url"] : false; // OR provide your own callback function for managing the update
array_push($premium_update, $plugin_data);
}
return $premium_update;
}
public static function flush_version_info() {
self::include_upgrade_library();
RGUserUpgrade::set_version_info(false);
}
public static function plugin_row(){
self::include_upgrade_library();
if(!self::is_gravityforms_supported()){
$message = sprintf(__("Gravity Forms " . self::$min_gravityforms_version . " is required. Activate it now or %spurchase it today!%s", "gravityformsuserregistration"), "<a href='http://www.gravityforms.com'>", "</a>");
RGUserUpgrade::display_plugin_message($message, true);
}
else{
$version_info = RGUserUpgrade::get_version_info(self::$slug, self::get_key(), self::$version);
if ( ! rgar($version_info, "is_valid_key" ) ) {
$new_version = version_compare(self::$version, rgar($version_info, "version"), '<') ? __('There is a new version of Gravity Forms User Registration Add-On available.', 'gravityformsuserregistration') .' <a class="thickbox" title="Gravity Forms User Registration Add-On" href="plugin-install.php?tab=plugin-information&plugin=' . self::$slug . '&TB_iframe=true&width=640&height=808">'. sprintf(__('View version %s Details', 'gravityformsuserregistration'), rgar($version_info, "version") ) . '</a>. ' : '';
$message = $new_version . sprintf(__('%sRegister%s your copy of Gravity Forms to receive access to automatic upgrades and support. Need a license key? %sPurchase one now%s.', 'gravityformsuserregistration'), '<a href="admin.php?page=gf_settings">', '</a>', '<a href="http://www.gravityforms.com">', '</a>') . '</div></td>';
RGUserUpgrade::display_plugin_message($message);
}
}
}
//Displays current version details on Plugin's page
public static function display_changelog() {
if( $_REQUEST['plugin'] != self::$slug )
return;
self::include_upgrade_library();
RGUserUpgrade::display_changelog( self::$slug, self::get_key(), self::$version );
}
public static function check_update($update_plugins_option){
self::include_upgrade_library();
return RGUserUpgrade::check_update( self::$path, self::$slug, self::$url, self::$slug, self::get_key(), self::$version, $update_plugins_option );
}
private static function get_key(){
if(self::is_gravityforms_supported())
return GFCommon::get_key();
else
return "";
}
public static function include_upgrade_library() {
if( ! class_exists( 'RGUserUpgrade' ) )
require_once( 'plugin-upgrade.php' );
}
//------------------------------------------------------------------------
// Creates User Registration left nav menu under Forms
public static function create_menu($menus){
// Adding submenu if user has access
$permission = self::has_access("gravityforms_user_registration");
if(!empty($permission))
$menus[] = array("name" => "gf_user_registration", "label" => __("User Registration", "gravityformsuserregistration"), "callback" => array("GFUser", "user_registration_page"), "permission" => $permission);
return $menus;
}
// Creates or updates database tables. Will only run when version changes
private static function setup(){
if( get_option( 'gf_user_registration_version' ) == self::$version )
return;
// loading data lib
require_once( self::get_base_path() . '/data.php' );
GFUserData::update_table();
// create signups table for non-multisite installs
if( ! is_multisite() ) {
require_once( self::get_base_path() . '/includes/signups.php' );
GFUserSignups::create_signups_table();
}
update_option( 'gf_user_registration_version', self::$version );
}
// Adds feed tooltips to the list of tooltips
public static function tooltips($tooltips){
$userregistration_tooltips = array(
"user_registration_gravity_form" => "<h6>" . __("Gravity Form", "gravityformsuserregistration") . "</h6>" . __("Select the Gravity Form you would like to use to register users for your WordPress website.", "gravityformsuserregistration"),
"user_registration_feed_type" => "<h6>" . __("Action", "gravityformsuserregistration") . "</h6>" . __("Select the type of feed you would like to create. \"Create\" feeds will create a new user. \"Update\" feeds will update users.", "gravityformsuserregistration"),
"user_registration_username" => "<h6>" . __("Username", "gravityformsuserregistration") . "</h6>" . __("Select the form field that should be used for the user's username.", "gravityformsuserregistration"),
"user_registration_firstname" => "<h6>" . __("First Name", "gravityformsuserregistration") . "</h6>" . __("Select the form field that should be used for the user's first name.", "gravityformsuserregistration"),
"user_registration_lastname" => "<h6>" . __("Last Name", "gravityformsuserregistration") . "</h6>" . __("Select the form field that should be used for the user's last name.", "gravityformsuserregistration"),
"user_registration_displayname" => "<h6>" . __("Display Name", "gravityformsuserregistration") . "</h6>" . __("Select how the user's name should be displayed publicly.", "gravityformsuserregistration"),
"user_registration_email" => "<h6>" . __("Email Address", "gravityformsuserregistration") . "</h6>" . __("Select the form field that should be used for the user's email address.", "gravityformsuserregistration"),
"user_registration_password" => "<h6>" . __("Password", "gravityformsuserregistration") . "</h6>" . __("Select the form field that should be used for the user's password.", "gravityformsuserregistration"),
"user_registration_role" => "<h6>" . __("Role", "gravityformsuserregistration") . "</h6>" . __("Select the role the user should be assigned.", "gravityformsuserregistration"),
"user_registration_notification" => "<h6>" . __("Send Email?", "gravityformsuserregistration") . "</h6>" . __("Specify whether to send the password to the new user by email. <em class=\"enabled-by-default\">Enabled by default.</em>", "gravityformsuserregistration"),
"user_registration_set_post_author" => "<h6>" . __("Set As Post Author", "gravityformsuserregistration") . "</h6>" . __("When a form submission creates a post and registers a user, set the new user as the post author. <em class=\"enabled-by-default\">Enabled by default.</em>", "gravityformsuserregistration"),
"user_registration_user_activation" => "<h6>" . __("User Activation", "gravityformsuserregistration") . "</h6>" . __("Send users an email with an activation link. Users are only registered once they have activated their accounts.", "gravityformsuserregistration"),
"user_registration_user_activation_type" => "<h6>" . __("User Activation Type", "gravityformsuserregistration") . "</h6>" . __("<strong>By Email:</strong> Send the user an email with an activation link.<br /><strong>Manually:</strong> Activate each user manually from the <a href=\"admin.php?page=gf_user_registration&view=pending_activations\">Pending Activations</a> page.", "gravityformsuserregistration"),
"user_registration_condition" => "<h6>" . __("Registration Condition", "gravityformsuserregistration") . "</h6>" . __("When the registration condition is enabled, form submissions will only register the user when the condition is met. When disabled the user will not be registered.", "gravityformsuserregistration"),
"user_registration_paypal_user_options" => "<h6>" . __("User Registration", "gravityformsuserregistration") . "</h6>" . __("The selected form also has a User Registration feed. These options allow you to specify how you would like the PayPal and User Registration Add-ons to work together.", "gravityformsuserregistration"),
"user_registration_multisite_create_site" => "<h6>" . __("Create Site", "gravityformsuserregistration") . "</h6>" . __("When WordPress Multisite is enabled, checking this option will enable the creation of a new site on the network when a new user registers.", "gravityformsuserregistration"),
"user_registration_multisite_site_address" => "<h6>" . __("Site Address", "gravityformsuserregistration") . "</h6>" . __("Select the form field that should be used for the site address.", "gravityformsuserregistration"),
"user_registration_multisite_site_title" => "<h6>" . __("Site Title", "gravityformsuserregistration") . "</h6>" . __("Select the form field that should be used for the site title.", "gravityformsuserregistration"),
"user_registration_multisite_site_role" => "<h6>" . __("Site Role", "gravityformsuserregistration") . "</h6>" . __("Select role the user should be assigned on the newly created site.", "gravityformsuserregistration"),
"user_registration_multisite_root_role" => "<h6>" . __("Current Site Role", "gravityformsuserregistration") . "</h6>" . __("Select role the user should be assigned on the site they registered from. This option overrides the \"Role\" option under User Settings.", "gravityformsuserregistration")
);
return array_merge($tooltips, $userregistration_tooltips);
}
public static function user_registration_page(){
$view = RGForms::get('view');
$id = RGForms::get('id');
if($view == 'edit') {
self::edit_page($id);
} else if($view == 'pending_activations') {
self::pending_activations_page($id);
} else {
self::list_page();
}
}
// List Page
private static function list_page() {
if(!self::is_gravityforms_supported()){
die(sprintf(__("User Registration Add-On requires Gravity Forms %s. Upgrade automatically on the %sPlugin page%s.", "gravityformsuserregistration"), self::$min_gravityforms_version, "<a href='plugins.php'>", "</a>"));
}
$action = RGForms::post("action");
$bulk_action = RGForms::post("bulk_action");
if($action == "delete"){
check_admin_referer("list_action", "gf_user_registration_list");
$id = absint($_POST["action_argument"]);
GFUserData::delete_feed($id);
?>
<div class="updated fade" style="padding:6px"><?php _e("Feed deleted.", "gravityformsuserregistration") ?></div>
<?php
}
else if (!empty($bulk_action)){
check_admin_referer("list_action", "gf_user_registration_list");
$selected_feeds = RGForms::post("feed");
if(is_array($selected_feeds)){
foreach($selected_feeds as $feed_id)
GFUserData::delete_feed($feed_id);
}
?>
<div class="updated fade" style="padding:6px"><?php _e("Feeds deleted.", "gravityformsuserregistration") ?></div>
<?php
}
?>
<div class="wrap">
<div style="background: url(<?php echo self::get_base_url() ?>/images/user-registration-icon-32.png) no-repeat;" id="icon-edit" class="icon32 icon32-posts-post"><br></div>
<h2>
<?php _e("User Registration Forms", "gravityformsuserregistration") ?>
<a href="<?php echo admin_url('admin.php?page=gf_user_registration&view=edit&id=0'); ?>" class="add-new-h2">Add New</a>
</h2>
<form id="feed_form" method="post">
<?php wp_nonce_field('list_action', 'gf_user_registration_list') ?>
<input type="hidden" id="action" name="action"/>
<input type="hidden" id="action_argument" name="action_argument"/>
<div class="tablenav">
<div class="alignleft actions" style="padding:8px 0 7px;">
<label class="hidden" for="bulk_action"><?php _e("Bulk action", "gravityformsuserregistration") ?></label>
<select name="bulk_action" id="bulk_action">
<option value=''> <?php _e("Bulk action", "gravityformsuserregistration") ?> </option>
<option value='delete'><?php _e("Delete", "gravityformsuserregistration") ?></option>
</select>
<?php
echo '<input type="submit" class="button" value="' . __("Apply", "gravityformsuserregistration") . '" onclick="if( jQuery(\'#bulk_action\').val() == \'delete\' && !confirm(\'' . __("Delete selected feeds? ", "gravityformsuserregistration") . __("\'Cancel\' to stop, \'OK\' to delete.", "gravityformsuserregistration") .'\')) { return false; } return true;"/>';
?>
</div>
</div>
<table class="widefat fixed" cellspacing="0">
<thead>
<tr>
<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
<th scope="col" id="active" class="manage-column check-column"></th>
<th scope="col" class="manage-column"><?php _e("Form", "gravityformsuserregistration") ?></th>
<th scope="col" class="manage-column"><?php _e("Action", "gravityformsuserregistration") ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
<th scope="col" id="active" class="manage-column check-column"></th>
<th scope="col" class="manage-column"><?php _e("Form", "gravityformsuserregistration") ?></th>
<th scope="col" class="manage-column"><?php _e("Action", "gravityformsuserregistration") ?></th>
</tr>
</tfoot>
<tbody class="list:user user-list">
<?php
$settings = GFUserData::get_feeds();
if(is_array($settings) && sizeof($settings) > 0){
foreach($settings as $setting){
?>
<tr class='author-self status-inherit' valign="top">
<th scope="row" class="check-column"><input type="checkbox" name="feed[]" value="<?php echo $setting["id"] ?>"/></th>
<td><img src="<?php echo self::get_base_url() ?>/images/active<?php echo intval($setting["is_active"]) ?>.png" alt="<?php echo $setting["is_active"] ? __("Active", "gravityformsuserregistration") : __("Inactive", "gravityformsuserregistration");?>" title="<?php echo $setting["is_active"] ? __("Active", "gravityformsuserregistration") : __("Inactive", "gravityformsuserregistration");?>" onclick="ToggleActive(this, <?php echo $setting['id'] ?>); " /></td>
<td class="column-title">
<a href="admin.php?page=gf_user_registration&view=edit&id=<?php echo $setting["id"] ?>" title="<?php _e("Edit", "gravityformsuserregistration") ?>"><?php echo $setting["form_title"] ?></a>
<div class="row-actions">
<span class="edit">
<a title="<?php _e("Edit", "gravityformsuserregistration")?>" href="admin.php?page=gf_user_registration&view=edit&id=<?php echo $setting["id"] ?>" title="<?php _e("Edit", "gravityformsuserregistration") ?>"><?php _e("Edit", "gravityformsuserregistration") ?></a> |
</span>
<?php if( self::is_pending_activation_enabled( $setting ) ) { ?>
<span class="edit">
<a title="<?php _e("Pending Activations", "gravityformsuserregistration") ?>" href="admin.php?page=gf_user_registration&view=pending_activations&form_id=<?php echo $setting['form_id']; ?>"><?php _e("Pending Activations", "gravityformsuserregistration")?></a> |
</span>
<?php } ?>
<span class="edit">
<a title="<?php _e("Delete", "gravityformsuserregistration") ?>" href="javascript: if(confirm('<?php _e("Delete this feed? ", "gravityformsuserregistration") ?> <?php _e("\'Cancel\' to stop, \'OK\' to delete.", "gravityformsuserregistration") ?>')){ DeleteSetting(<?php echo $setting["id"] ?>);}"><?php _e("Delete", "gravityformsuserregistration")?></a>
</span>
</div>
</td>
<td>
<?php
$feed_action = rgars($setting, 'meta/feed_type');
echo $feed_action == 'update' ? __('Update') : __('Create');
?>
</td>
</tr>
<?php
}
}
else{
?>
<tr>
<td colspan="3" style="padding:20px;">
<?php echo sprintf(__("You don't have any User Registration feeds configured. Let's go %screate one%s!", "gravityformsuserregistration"), '<a href="admin.php?page=gf_user_registration&view=edit&id=0">', "</a>"); ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</form>
</div>
<script type="text/javascript">
function DeleteSetting(id){
jQuery("#action_argument").val(id);
jQuery("#action").val("delete");
jQuery("#feed_form")[0].submit();
}
function ToggleActive(img, feed_id){
var is_active = img.src.indexOf("active1.png") >=0
if(is_active){
img.src = img.src.replace("active1.png", "active0.png");
jQuery(img).attr('title','<?php _e("Inactive", "gravityformsuserregistration") ?>').attr('alt', '<?php _e("Inactive", "gravityformsuserregistration") ?>');
}
else{
img.src = img.src.replace("active0.png", "active1.png");
jQuery(img).attr('title','<?php _e("Active", "gravityformsuserregistration") ?>').attr('alt', '<?php _e("Active", "gravityformsuserregistration") ?>');
}
var mysack = new sack(ajaxurl);
mysack.execute = 1;
mysack.method = 'POST';
mysack.setVar( "action", "rg_user_update_feed_active" );
mysack.setVar( "rg_user_update_feed_active", "<?php echo wp_create_nonce("rg_user_update_feed_active") ?>" );
mysack.setVar( "feed_id", feed_id );
mysack.setVar( "is_active", is_active ? 0 : 1 );
mysack.encVar( "cookie", document.cookie, false );
mysack.onError = function() { alert('<?php echo esc_js(__("Ajax error while updating feed", "gravityformsuserregistration" )) ?>' )};
mysack.runAJAX();
return true;
}
</script>
<?php
}
public static function settings_page(){
$ur_settings = get_option('gf_userregistration_settings') ? get_option('gf_userregistration_settings') : array();
$uninstall = RGForms::post("uninstall");
if($uninstall){
check_admin_referer("uninstall", "gf_user_registration_uninstall");
self::uninstall();
?>
<div class="updated fade" style="padding:20px;">
<?php echo sprintf(__("Gravity Forms User Registration Add-On has been successfully uninstalled. It can be re-activated from the %splugins page%s.", "gravityformsuserregistration"), "<a href='plugins.php'>","</a>"); ?>
</div>
<?php
return;
}
$is_submit = rgpost('gf_userregistration_settings_submit');
if($is_submit){
$ur_settings['enable_custom_reg_page'] = rgpost('gf_userregistration_enable_custom_reg_page');
$ur_settings['custom_reg_page'] = rgpost('gf_userregistration_custom_reg_page');
update_option('gf_userregistration_settings', $ur_settings);
}
?>
<form method="post">
<?php wp_nonce_field("update", "gf_userregistration_update") ?>
<input type="hidden" value="1" name="gf_userregistration_settings_submit" />
<h3><?php _e("User Registration Settings", "gravityformsuserregistration") ?></h3>
<table width="100%">
<tr>
<td valign="top" width="260"><?php _e("Custom Registration Page", "gravityformsuserregistration") ?></td>
<td valign="top">
<input type="checkbox" name="gf_userregistration_enable_custom_reg_page" id="gf_userregistration_enable_custom_reg_page" <?php echo rgar($ur_settings, 'enable_custom_reg_page') ? "checked='checked'" : "" ?> onclick="if(jQuery(this).is(':checked')) { jQuery('#gf_userregistration_custom_reg_page_options').slideDown(); } else { jQuery('#gf_userregistration_custom_reg_page_options').slideUp(); }" />
<label for="gf_userregistration_enable_custom_reg_page" class="inline"><?php _e("Enable Custom Registration Page", "gravityformsuserregistration") ?> <?php gform_tooltip("user_registration_username") ?></label>
<div id="gf_userregistration_custom_reg_page_options" style="<?php echo !rgar($ur_settings, 'enable_custom_reg_page') ? 'display:none;' : ''; ?> margin: 10px 0;">
<?php $pages = get_posts('post_type=page&numberposts=-1&order=asc&orderby=title'); ?>
<select id="gf_userregistration_custom_reg_page" name="gf_userregistration_custom_reg_page">
<?php foreach($pages as $page){
$selected = $page->ID == rgar($ur_settings, 'custom_reg_page') ? "selected='selected'" : "";
?>
<option value="<?php echo $page->ID; ?>" <?php echo $selected ?>><?php echo $page->post_title; ?></option>
<?php } ?>
</select>
</div>
</td>
</tr>
</table>
<input type="submit" name="save" value="<?php _e("Save Settings", "gravityformsuserregistration") ?>" class="button-primary" style="margin-top:40px;" />
</form>
<form action="" method="post">
<?php wp_nonce_field("uninstall", "gf_user_registration_uninstall") ?>
<?php if(GFCommon::current_user_can_any("gravityforms_user_registration_uninstall")){ ?>
<div class="hr-divider"></div>
<h3><?php _e("Uninstall User Registration Add-On", "gravityformsuserregistration") ?></h3>
<div class="delete-alert alert_red">
<h3><i class="fa fa-exclamation-triangle gf_invalid"></i> Warning</h3>
<div class="gf_delete_notice" "=""><strong><?php _e("Warning! This operation deletes ALL user registration feeds.", "gravityformsuserregistration") ?></strong><?php _e("If you continue, you will not be able to recover any User Registration data.", "gravityformsuserregistration") ?>
</div>
<input type="submit" name="uninstall" value="Uninstall User Registration Add-on" class="button" onclick="return confirm('<?php _e("Warning! ALL settings will be deleted. This cannot be undone. \'OK\' to delete, \'Cancel\' to stop", "gravityformsuserregistration") ?>');">
</div>
<?php } ?>
</form>
<?php
}
// Edit Page
private static function edit_page(){
?>
<style type="text/css">
#user_registration_submit_container{clear:both;}
.user_registration_col_heading{padding-bottom:2px; border-bottom: 1px solid #ccc; font-weight:bold; width:120px;}
.user_registration_field_cell {padding: 6px 17px 0 0; margin-right:15px;}
.user_registration_validation_error{ background-color:#ffebe8; margin: 4px 0 6px; padding: 6px; border: 1px dotted #cc0000; }
.left_header { float:left; width: 260px;}
.column_right { margin-left: 260px; }
.margin_vertical_10{margin: 10px 0; padding-left:5px;}
.margin_vertical_30{margin: 30px 0; padding-left:5px;}
.width-1{width:300px;}
.error { }
.error li { list-style: disc; margin-left: 20px; }
.error_message { margin-top: 30px; background-color: #ffebe8; border: 1px solid #cc0000; padding: 10px; width: 600px;
border-radius: 3px; }
.spinner { position: relative; top: 4px; left: 5px; }
.hide-label { display: none; }
.enabled-by-default { color: #999; }
div.custom_metaname { position: relative; }
span.reset { background:url("images/xit.gif") no-repeat scroll 0 -10px transparent; cursor:pointer; display:block;
position:absolute; text-indent:-9999px; width:10px; height: 10px; right: 16px; top: 7px; }
.hover span.reset { background-position: 0 0; }
option.label { font-style: italic; color: #999; }
.metaname, .metavalue { float: left; }
.metavalue { margin-left: 30px; }
.metaname .width-1 { margin-right: 10px; width: 220px; }
.add_field_choice, .delete_field_choice { margin: 3px 0 4px 3px; }
.custom_usermeta .margin_vertical_10 { overflow: hidden; margin-bottom: 0; }
.custom_usermeta option.custom { font-weight: bold; }
.custom_metaname { float: left; }
.notice { font-size: 12px; font-style: italic; color: #aaa; }
.system-option, .password-field option:last-child { font-style: italic; }
.checkbox-label { font-size: 12px; }
.disabled label { color: #999; }
#field_group { overflow: hidden; } /* fixed issue with jumpy aniatmion in jQuery */
form.update { }
form.update #option_username { display: none; }
form.update #option_user_activation { display: none; }
form.update label.email span { display: none; }
#gfur_user_activation_type_container { display: inline; }
</style>
<div class="wrap">
<div style="background: url(<?php echo self::get_base_url() ?>/images/user-registration-icon-32.png) no-repeat;" id="icon-edit" class="icon32 icon32-posts-post"><br></div>
<h2>
<?php _e("User Registration Settings", "gravityformsuserregistration") ?>
</h2>
<?php
//getting setting id (0 when creating a new one)
$id = RGForms::post("user_registration_setting_id");
$id = !empty($id) ? $id : absint(RGForms::get("id"));
$config = empty($id) ? array("meta" => array(), "is_active" => true) : GFUserData::get_feed($id);
$is_validation_error = false;
$error_messages = array();
$is_update_feed = rgars($config, 'meta/feed_type') == 'update';
// if this is an existing feed and no feed type is specified, default to "create"
if($id && !rgars($config, 'meta/feed_type'))
$config['meta']['feed_type'] = 'create';
// handle submission
$is_submit = RGForms::post("gf_user_registration_submit");
if(!empty($is_submit) && check_admin_referer('user_registration_edit_submit','user_registration_edit_submit')){
$form_id = RGForms::post("gf_user_registration_form");
$config["form_id"] = absint($form_id);
// feed action; set to create if blank for old feeds
$config["meta"]["feed_type"] = rgpost("feed_type") ? rgpost("feed_type") : 'create';
$is_update_feed = rgars($config, 'meta/feed_type') == 'update';
// standard meta
$config["meta"]["username"] = $is_update_feed ? '' : rgpost("gf_user_registration_username");
$config["meta"]["firstname"] = rgpost("gf_user_registration_firstname");
$config["meta"]["lastname"] = rgpost("gf_user_registration_lastname");
$config["meta"]["displayname"] = rgpost("gf_user_registration_displayname");
$config["meta"]["email"] = rgpost("gf_user_registration_email");
$config["meta"]["password"] = rgpost("gf_user_registration_password");
$config["meta"]["role"] = rgpost("gf_user_registration_role");
// user meta
$json = stripslashes(RGForms::post("gf_user_meta"));
$config["meta"]["user_meta"] = GFCommon::json_decode($json);
//clean user meta (workaround to avoid values being marked as array)
if(is_array($config["meta"]["user_meta"])){
foreach($config["meta"]["user_meta"] as &$meta){
if(is_array($meta["meta_value"])){
$meta["meta_value"] = $meta["meta_value"][0];
}
}
}
// registration condition
$config['meta']['reg_condition_enabled'] = RGForms::post('gf_user_registration_enabled');
$config['meta']['reg_condition_field_id'] = RGForms::post('gf_user_registration_field_id');
$config['meta']['reg_condition_operator'] = RGForms::post('gf_user_registration_operator');
$config['meta']['reg_condition_value'] = RGForms::post('gf_user_registration_value');
// additional meta options
$config['meta']['notification'] = RGForms::post('gf_user_registration_notification');
$config['meta']['set_post_author'] = RGForms::post('gf_user_registration_set_post_author');
$config['meta']['user_activation'] = $is_update_feed ? false : RGForms::post('gf_user_registration_user_activation');
$config['meta']['user_activation_type'] = $is_update_feed || !$config['meta']['user_activation'] ? false : rgpost('gf_user_registration_user_activation_type');
// use to save custom config options (used by BuddyPress)
$config = apply_filters("gform_user_registration_save_config", $config);
// deprecated in favor of new method for generating error messages, preserved for users who may be using this
$is_validation_error = apply_filters("gform_user_registration_config_validation", false, $config);
if(!$config["meta"]["email"] && !$is_update_feed)
$error_messages[] = __('You must map the "Email Address" setting to a field.', 'gravityformsuserregistration');
if(!$config["meta"]["username"] && !$is_update_feed)
$error_messages[] = __('You must map the "Username" setting to a field.', 'gravityformsuserregistration');
$error_messages = apply_filters('gform_user_confirm_validation_error', $error_messages, $config);
// validate and create/update feed
if(empty($error_messages)) {
$id = GFUserData::update_feed($id, $config["form_id"], $config["is_active"], $config["meta"]);
?>
<div class="updated fade">
<p><?php echo sprintf(__("Feed Updated. %sback to list%s", "gravityformsuserregistration"), "<a href='?page=gf_user_registration'>", "</a>") ?></p>
</div>
<?php
}
else {
$is_validation_error = true;
}
}
$form = (isset($config["form_id"]) && $config["form_id"]) ? RGFormsModel::get_form_meta($config["form_id"]) : array();
$form_fields = $email_fields = $selection_fields = $password_fields = array();
$set_author_style = 'display:none';
if( ! empty( $form ) ) {
$set_author_style = (GFCommon::has_post_field($form['fields'])) ? 'display:block' : 'display:none';
$form_fields = self::get_form_fields($form, $is_update_feed);
$email_fields = self::get_fields_by_type($form, 'email');
$selection_fields = GFCommon::get_selection_fields($form, $config['meta']['reg_condition_field_id']);
// add custom option to password fields
$password_default = $is_update_feed ? array(array('', __('Preserve current password', 'gravityformsuserregistration') )) : array(array('', __('Auto Generate Password', 'gravityformsuserregistration') ));
$password_fields = self::get_fields_by_type($form, 'password');// ? self::get_fields_by_type($form, 'password') : array();
$password_fields = array_merge($password_fields, $password_default);
}
if(!empty($error_messages)) { ?>
<div class="error">
<p><?php _e('Oops! There were some issues with your feed.', 'gravityformsuserregistration'); ?></p>
<ul><li><?php echo implode('</li><li>', $error_messages); ?></li></ul>
</div>
<?php } ?>
<form method="post" action="" id="gf_user_form" class="<?php echo rgars($config, 'meta/feed_type'); ?>">
<input type="hidden" name="user_registration_setting_id" value="<?php echo $id ?>" />
<input type="hidden" name="gf_user_meta" id="gf_user_meta" value="" />
<?php wp_nonce_field('user_registration_edit_submit','user_registration_edit_submit'); ?>
<div id="feed_settings">
<h3>Feed Settings</h3>
<div class="margin_vertical_10">
<label class="left_header" for="gf_user_registration_action"><?php _e("Action", "gravityformsuserregistration"); ?> <?php gform_tooltip("user_registration_feed_type") ?></label>
<select id="feed_type" name="feed_type" onchange="setFeedType(this);">
<option value=""><?php _e('Select an Action', 'gravityformsuserregistration'); ?></option>
<?php
$action = rgars($config, 'meta/feed_type');
foreach(array('create' => 'Create User', 'update' => 'Update User') as $value => $label) {
$selected = $action == $value ? 'selected="selected"' : '';
echo "<option value=\"$value\" $selected>$label</option>";
} ?>
</select>
</div> <!-- feed_type -->
<div id="form_select" class="margin_vertical_10" <?php echo !rgar($config, 'form_id') ? "style='display:none;'" : "" ?>>
<label for="gf_user_registration_form" class="left_header"><?php _e("Gravity Form", "gravityformsuserregistration"); ?> <?php gform_tooltip("user_registration_gravity_form") ?></label>
<select id="gf_user_registration_form" name="gf_user_registration_form" onchange="SelectForm(jQuery(this).val(), '<?php echo $id; ?>');">
<?php
$available_forms = GFUserData::get_available_forms(rgars($config, 'meta/feed_type'), $id);
echo self::create_form_select_options($available_forms, $config);
?>
</select>
</div> <!-- / select form -->
</div> <!-- / feed_settings -->
<div id="field_group" valign="top" <?php echo empty($config["form_id"]) ? "style='display:none;'" : "" ?>>
<div id="standard_fields">
<h3>User Settings</h3>
<div id="option_username" class="margin_vertical_10 <?php echo ($is_validation_error && empty($config['meta']['username'])) ? 'user_registration_validation_error' : ''; ?>">
<label class="left_header" for="gf_user_registration_username"><?php _e("Username", "gravityformsuserregistration"); ?> <span class="description">(<?php _e("required", "gravityformsuserregistration"); ?>)</span> <?php gform_tooltip("user_registration_username") ?></label>
<?php echo self::get_field_drop_down("gf_user_registration_username", $form_fields, rgar($config['meta'], 'username'), "width-1 standard-meta"); ?>
</div>
<div class="margin_vertical_10">
<label class="left_header" for="gf_user_registration_firstname"><?php _e("First Name", "gravityformsuserregistration"); ?> <?php gform_tooltip("user_registration_firstname") ?></label>
<?php echo self::get_field_drop_down("gf_user_registration_firstname", $form_fields, rgar($config['meta'], 'firstname'), "width-1 standard-meta"); ?>
</div>
<div class="margin_vertical_10">
<label class="left_header" for="gf_user_registration_lastname"><?php _e("Last Name", "gravityformsuserregistration"); ?> <?php gform_tooltip("user_registration_lastname") ?></label>
<?php echo self::get_field_drop_down("gf_user_registration_lastname", $form_fields, rgar($config['meta'], 'lastname'), "width-1 standard-meta"); ?>
</div>
<div class="margin_vertical_10">
<label class="left_header" for="gf_user_registration_displayname">
<?php _e("Display Name", "gravityformsuserregistration"); ?> <?php gform_tooltip("user_registration_displayname") ?>
</label>
<?php $display_names = array(
'username' => '{username}',
'firstname' => '{first name}',
'lastname' => '{last name}',
'firstlast' => '{first name} {last name}',
'lastfirst' => '{last name} {first name}'
);
?>
<select id="gf_user_registration_displayname" name="gf_user_registration_displayname" class="width-1">
<?php foreach($display_names as $key => $value) {
$selected = rgar($config['meta'], 'displayname') == $key ? 'selected="selected"' : '';
?>
<option value="<?php echo $key; ?>" <?php echo $selected; ?>><?php echo $value; ?></option>
<?php } ?>
</select>
</div>
<div class="margin_vertical_10 <?php echo ($is_validation_error && empty($config['meta']['email'])) ? 'user_registration_validation_error' : ''; ?>">
<label class="left_header email" for="gf_user_registration_email"><?php _e("Email Address", "gravityformsuserregistration"); ?> <span class="description">(<?php _e("required", "gravityformsuserregistration"); ?>)</span> <?php gform_tooltip("user_registration_email") ?></label>
<?php echo self::get_field_drop_down("gf_user_registration_email", $email_fields, rgar($config['meta'], 'email'), "width-1 email-field"); ?>
</div>
<div class="margin_vertical_10">
<label class="left_header" for="gf_user_registration_password"><?php _e("Password", "gravityformsuserregistration"); ?> <?php gform_tooltip("user_registration_password") ?></label>
<?php echo self::get_field_drop_down("gf_user_registration_password", $password_fields, rgar($config['meta'], 'password'), "width-1 password-field", false); ?>
</div>
<?php $disabled = is_multisite() && rgars($config['meta'], 'multisite_options/create_site') ? 'disabled="disabled"' : ''; ?>
<div class="margin_vertical_10 <?php echo $disabled ? 'disabled' : '' ?>">
<label class="left_header" for="gf_user_registration_role"><?php _e("Role", "gravityformsuserregistration"); ?> <?php gform_tooltip("user_registration_role") ?></label>
<select id="gf_user_registration_role" name="gf_user_registration_role" class="width-1" <?php echo $disabled; ?>>
<?php if( is_multisite() && rgars( $config, 'meta/multisite_options/create_site' ) ): ?>
<option value="" selected="selected" class="empty-option"></option>
<?php endif; ?>
<?php self::display_role_dropdown_options( rgars( $config, 'meta/role' ), false, self::is_update_feed( $config ) ); ?>
</select>
</div>
</div> <!-- / standard fields -->
<div id="user_meta_fields">
<h3>User Meta</h3>
<div id="custom_usermeta" class="custom_usermeta"></div>
</div> <!-- / user meta fields -->
<?php do_action("gform_user_registration_add_option_section", $config, $form, $is_validation_error); // buddypress, networkmode
?>
<div id="additional_options">
<h3>Additional Options</h3>
<div id="gf_user_registration_send_email" class="margin_vertical_10" style="<?php echo $is_update_feed ? 'display:none;' : ''; ?>">
<label class="left_header"><?php _e("Send Email?", "gravityformsuserregistration"); ?> <?php gform_tooltip("user_registration_notification") ?></label>
<input type="checkbox" id="gf_user_registration_notification" name="gf_user_registration_notification" value="1" <?php echo (rgar($config['meta'], 'notification') == 1 || !isset($config["meta"]["notification"])) ? "checked='checked'" : ""?> />
<label for="gf_user_registration_notification" class="checkbox-label"><?php _e("Send this password to the new user by email.", "gravityformsuserregistration"); ?></label>
</div> <!-- / send email? -->
<div id="gf_user_registration_set_post_author_container" class="margin_vertical_10" style="<?php echo $set_author_style; ?>">
<label class="left_header"><?php _e("Set As Post Author", "gravityformsuserregistration"); ?> <?php gform_tooltip("user_registration_set_post_author") ?></label>
<input type="checkbox" id="gf_user_registration_set_post_author" name="gf_user_registration_set_post_author" value="1" <?php echo (rgar($config['meta'], 'set_post_author') == 1 || !isset($config["meta"]["set_post_author"])) ? "checked='checked'" : ""?> />
<label for="gf_user_registration_set_post_author" class="checkbox-label"><?php _e("Enable", "gravityformsuserregistration"); ?></label>
</div> <!-- / set post author -->
<div id="option_user_activation" class="margin_vertical_10">
<?php $user_activation_enabled = rgar($config['meta'], 'user_activation') == true; ?>
<label class="left_header" for="gf_user_registration_user_activation">
<?php _e( 'User Activation', 'gravityformsuserregistration' ); ?>
<?php gform_tooltip( 'user_registration_user_activation' ); ?>
</label>
<input type="checkbox" id="gf_user_registration_user_activation" name="gf_user_registration_user_activation" value="1" <?php echo rgar($config['meta'], 'user_activation') ? "checked='checked'" : ""?> onclick="ToggleUserActivation();" />
<label for="gf_user_registration_user_activation" class="checkbox-label">
<span class="unselected" style="<?php echo !$user_activation_enabled ? '' : 'display:none;'; ?>"><?php _e( 'Enable user activation.', 'gravityformsuserregistration' ); ?></span>
<span class="selected" style="<?php echo $user_activation_enabled ? '' : 'display:none;'; ?>"><?php _e( 'Enable user activation', 'gravityformsuserregistration' ); ?></span>
</label>
<div id="gfur_user_activation_type_container" style="<?php echo rgar($config['meta'], 'user_activation') ? '' : 'display:none;'; ?>">
<select id="gf_user_registration_user_activation_type" name="gf_user_registration_user_activation_type">
<?php $user_activation_options = array( 'email' => 'by email', 'manual' => 'manually' ); ?>
<?php foreach( $user_activation_options as $value => $label ): ?>
<option value="<?php echo $value; ?>" <?php selected( rgar($config['meta'], 'user_activation_type'), $value ); ?> ><?php echo $label; ?></option>
<?php endforeach; ?>
</select>
<?php gform_tooltip( 'user_registration_user_activation_type' ); ?>
</div>
</div> <!-- / user activation -->
<div id="gf_user_registration_section" valign="top" class="margin_vertical_10">
<label for="gf_user_registration_optin" class="left_header"><?php _e("Registration Condition", "gravityformsuserregistration"); ?> <?php gform_tooltip("user_registration_condition") ?></label>
<div id="gf_user_registration_option" class="column_right">
<input type="checkbox" id="gf_user_registration_enabled" name="gf_user_registration_enabled" value="1" onclick="if(this.checked){jQuery('#gf_user_registration_container').fadeIn('fast');} else{jQuery('#gf_user_registration_container').fadeOut('fast');}" <?php echo rgar($config['meta'], 'reg_condition_enabled') ? "checked='checked'" : ""?>/>
<label for="gf_user_registration_enabled" class="checkbox-label"><?php _e("Enable", "gravityformsuserregistration"); ?></label>
<div id="gf_user_registration_container" style="padding-top:5px; <?php echo !$config["meta"]["reg_condition_enabled"] ? "display:none" : ""?>">
<div id="gf_user_registration_condition_fields" style="display:none">
<?php _e("Register the user if ", "gravityformsuserregistration") ?>
<select id="gf_user_registration_field_id" name="gf_user_registration_field_id" class='optin_select' onchange='jQuery("#gf_user_registration_value_container").html(GetFieldValues(jQuery(this).val(), "", 20));'></select>
<select id="gf_user_registration_operator" name="gf_user_registration_operator">
<option value="is" <?php echo rgar($config['meta'], 'reg_condition_operator') == 'is' ? 'selected="selected"' : '' ?>><?php _e("is", "gravityformsuserregistration") ?></option>
<option value="isnot" <?php echo rgar($config['meta'], 'reg_condition_operator') == "isnot" ? 'selected="selected"' : '' ?>><?php _e("is not", "gravityformsuserregistration") ?></option>
<option value=">" <?php echo rgar($config['meta'], 'reg_condition_operator') == ">" ? "selected='selected'" : "" ?>><?php _e("greater than", "gravityformsuserregistration") ?></option>
<option value="<" <?php echo rgar($config['meta'], 'reg_condition_operator') == "<" ? "selected='selected'" : "" ?>><?php _e("less than", "gravityformsuserregistration") ?></option>
<option value="contains" <?php echo rgar($config['meta'], 'reg_condition_operator') == "contains" ? "selected='selected'" : "" ?>><?php _e("contains", "gravityformsuserregistration") ?></option>
<option value="starts_with" <?php echo rgar($config['meta'], 'reg_condition_operator') == "starts_with" ? "selected='selected'" : "" ?>><?php _e("starts with", "gravityformsuserregistration") ?></option>
<option value="ends_with" <?php echo rgar($config['meta'], 'reg_condition_operator') == "ends_with" ? "selected='selected'" : "" ?>><?php _e("ends with", "gravityformsuserregistration") ?></option>
</select>
<div id="gf_user_registration_value_container" name="gf_user_registration_value_container" style="display:inline;"></div>
</div>
<div id="gf_user_registration_condition_message" style="display:none">
<?php _e("To create a registration condition, your form must have a field supported by conditional logic.", "gravityformsuserregistration") ?>
</div>
</div>
</div>
</div> <!-- / registration conditional -->
<?php do_action("gform_user_registration_add_option_group", $config, $form, $is_validation_error); ?>
<div id="user_registration_submit_container" class="margin_vertical_30">
<input type="submit" name="gf_user_registration_submit" value="<?php echo empty($id) ? __("Save", "gravityformsuserregistration") : __("Update", "gravityformsuserregistration"); ?>" class="button-primary"/>
<input type="button" value="<?php _e("Cancel", "gravityformsuserregistration"); ?>" class="button" onclick="javascript:document.location='admin.php?page=gf_user_registration'" />
</div> <!-- / form actions -->
</div> <!-- / additional options -->
</div> <!-- / field group -->
</form>
</div> <!-- / wrap -->
<script type="text/javascript">
<?php
$user_meta = rgar($config['meta'], 'user_meta');
$meta_keys = self::get_user_meta_keys(array('user_url', 'aim', 'yim', 'jabber', 'description'));
?>
var GFUser = {
form: <?php echo !empty($form) ? GFCommon::json_encode($form) : 'new Array()'; ?>,
form_fields: <?php echo (!empty($form_fields)) ? GFCommon::json_encode($form_fields) : "new Array()"; ?>,
form_id: <?php echo rgar($config, 'form_id') ? rgar($config, 'form_id') : "''" ?>,
user_meta: <?php echo !empty($user_meta) ? GFCommon::json_encode($user_meta) : "[new MetaOption()]"; ?>,
bp_gform_options: <?php echo (!empty($form)) ? GFCommon::json_encode(self::get_bp_gform_fields($form)) : "''"; ?>,
meta_names: [
{ 'name': 'Standard User Meta', 'value': '_optgroup' },
{ 'name': 'Website', 'value': 'user_url' },
{ 'name': 'AIM', 'value': 'aim' },
{ 'name': 'Yahoo', 'value': 'yim' },
{ 'name': 'Jabber / Google Talk', 'value': 'jabber' },
{ 'name': 'Biographical Information', 'value': 'description' }
<?php if(!empty($meta_keys)): ?>
,
{ 'name': 'Other User Meta', 'value': '_optgroup' }
<?php foreach($meta_keys as $meta_key): ?>
,