PluginProbe
Private groups / 2.3
Private groups v2.3
trunk 1.5 1.6 1.7 1.8 1.8.1 1.9.1 1.9.2 2.0 2.0.1 2.2 2.3 2.4 2.5 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 All 116 releases
← All changes | includes/user-profile.php +39 -26 1.72.3 View file →
@@ -13,29 +13,42 @@
13 13 ?>
14 14 <table class="form-table">
15 15 <tbody>
16 16 <tr>
17 - <th><label for="bbp-private-groups"><?php esc_html_e( 'Group', 'private-groups' ); ?></label></th>
17 + <th><label for="bbp-private-groups"><?php esc_html_e( 'Private Groups', 'private-groups' ); ?></label></th>
18 18 <td>
19 19
20 - <select name="bbp-private-groups" id="group">
21 20 <?php global $rpg_groups ;
22 21 if (empty( $rpg_groups ) ) : ?>
23 -
22 +
24 23 <option value=""><?php esc_html_e( '&mdash; No groups yet set up &mdash;', 'private-groups' ); ?></option>
25 24
26 25 <?php else : ?>
27 - <?php $private_group = get_user_meta($user_id, 'private_group', true); ?>
28 - <option value="" selected="selected"><?php esc_html_e( '&mdash; No group &mdash;', 'bbpress' ); ?></option>
29 -
26 +
27 +
28 + <!-- checkbox to activate -->
29 + <?php $private_group = get_user_meta($user_id, 'private_group', true); ?>
30 +
31 +
32 + <?php foreach ( $rpg_groups as $group => $details ) : ?>
33 + <tr valign="top">
34 + <th><?php echo $group." ".$details ; ?></th>
35 + <td>
36 + <?php
37 + $check=0 ;
38 + if (strpos($private_group, '*'.$group.'*') !== FALSE) $check=1 ;
39 + elseif($private_group == $group) $check=1 ;
40 + //echo $check;
41 + echo '<input name="'.$group.'" id="group" type="checkbox" ' ;
42 + if( $check ) echo 'checked="checked"';
43 + echo ' /> Click to add this group';
44 + ?>
45 + </td>
46 + </tr>
47 + <?php endforeach; ?>
30 48 <?php endif; ?>
49 +
31 50
32 - <?php foreach ( $rpg_groups as $group => $details ) : ?>
33 -
34 - <option <?php selected( $private_group, $group ); ?> value="<?php echo esc_attr( $group ); ?>"><?php echo $group.' '.$details ; ?></option>
35 -
36 - <?php endforeach; ?>
37 -
38 51 </select>
39 52 </td>
40 53 </tr>
41 54
@@ -49,20 +62,20 @@
49 62
50 63 // User profile edit/display actions
51 64 add_action( 'edit_user_profile', 'rpg_user_profile_field', 50,2 ) ;
52 65
53 -function bbp_edit_user_rpg( $user_id ) {
54 - $private_group = ( $_POST['bbp-private-groups'] ) ;
55 -
66 +function bbp_edit_user_pg( $user_id ) {
67 + global $rpg_groups ;
68 + $string='*' ;
69 + foreach ( $rpg_groups as $pggroup => $details) {
70 + $item='private_group_'.$pggroup ;
71 + $data = ($_POST[$pggroup] );
72 + if ($data=='on') {
73 + $string=$string.$pggroup.'*' ;
74 + }
75 + }
76 + if ($string=='*') $string = '' ;
77 + update_user_meta( $user_id, 'private_group', $string);
78 + }
56 79
57 - // Update town user meta
58 - if ( !empty( $private_group ) )
59 - update_user_meta( $user_id, 'private_group', $private_group);
80 +add_action( 'edit_user_profile_update', 'bbp_edit_user_pg' );
60 81
61 - // Delete town user meta
62 - else
63 - delete_user_meta( $user_id, 'private_group' );
64 -
65 -
66 -}
67 -
68 -add_action( 'edit_user_profile_update', 'bbp_edit_user_rpg' );