PluginProbe
Private groups / 2.4
Private groups v2.4
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
bbp-private-groups / includes / user-profile.php

user-profile.php in Private groups 2.4, at includes/user-profile.php

82 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 function rpg_user_profile_field() {
3 global $current_user;
4 global $rpg_groups ;
5
6
7
8 if (isset($_REQUEST['user_id'])) {
9 $user_id = $_REQUEST['user_id'];
10 } else {
11 $user_id = $current_user->ID;
12 }
13 ?>
14 <table class="form-table">
15 <tbody>
16 <tr>
17 <th><label for="bbp-private-groups"><?php esc_html_e( 'Private Groups', 'private-groups' ); ?></label></th>
18 <td>
19
20 <?php global $rpg_groups ;
21 if (empty( $rpg_groups ) ) : ?>
22
23 <option value=""><?php esc_html_e( '&mdash; No groups yet set up &mdash;', 'private-groups' ); ?></option>
24
25 <?php else : ?>
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; ?>
48 <?php endif; ?>
49
50
51 </select>
52 </td>
53 </tr>
54
55 </tbody>
56 </table>
57 <?php
58
59
60 }
61
62
63 // User profile edit/display actions
64 add_action( 'edit_user_profile', 'rpg_user_profile_field', 50,2 ) ;
65
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 }
79
80 add_action( 'edit_user_profile_update', 'bbp_edit_user_pg' );
81
82