PluginProbe
Private groups / 2.0
Private groups v2.0
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.0, at includes/user-profile.php

68 lines 1.7 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( 'Group', 'private-groups' ); ?></label></th>
18 <td>
19
20 <select name="bbp-private-groups" id="group">
21 <?php global $rpg_groups ;
22 if (empty( $rpg_groups ) ) : ?>
23
24 <option value=""><?php esc_html_e( '&mdash; No groups yet set up &mdash;', 'private-groups' ); ?></option>
25
26 <?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
30 <?php endif; ?>
31
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 </select>
39 </td>
40 </tr>
41
42 </tbody>
43 </table>
44 <?php
45
46
47 }
48
49
50 // User profile edit/display actions
51 add_action( 'edit_user_profile', 'rpg_user_profile_field', 50,2 ) ;
52
53 function bbp_edit_user_rpg( $user_id ) {
54 $private_group = ( $_POST['bbp-private-groups'] ) ;
55
56
57 // Update town user meta
58 if ( !empty( $private_group ) )
59 update_user_meta( $user_id, 'private_group', $private_group);
60
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' );