Changeset 7960 for trunk/bp-xprofile/bp-xprofile-actions.php
- Timestamp:
- 02/21/2014 11:08:04 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/bp-xprofile-actions.php
r6291 r7960 44 44 } 45 45 add_action( 'bp_actions', 'xprofile_action_delete_avatar' ); 46 47 /** 48 * Handles the saving of xprofile field visibilities 49 * 50 * @since BuddyPress (1.9) 51 */ 52 function bp_xprofile_action_settings() { 53 54 // Bail if not a POST action 55 if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) { 56 return; 57 } 58 59 // Bail if no submit action 60 if ( ! isset( $_POST['xprofile-settings-submit'] ) ) { 61 return; 62 } 63 64 // Bail if not in settings 65 if ( ! bp_is_user_settings_profile() ) { 66 return; 67 } 68 69 // 404 if there are any additional action variables attached 70 if ( bp_action_variables() ) { 71 bp_do_404(); 72 return; 73 } 74 75 // Nonce check 76 check_admin_referer( 'bp_xprofile_settings' ); 77 78 do_action( 'bp_xprofile_settings_before_save' ); 79 80 /** Save ******************************************************************/ 81 82 // Only save if there are field ID's being posted 83 if ( ! empty( $_POST['field_ids'] ) ) { 84 85 // Get the POST'ed field ID's 86 $posted_field_ids = explode( ',', $_POST['field_ids'] ); 87 88 // Save the visibility settings 89 foreach ( $posted_field_ids as $field_id ) { 90 91 $visibility_level = 'public'; 92 93 if ( !empty( $_POST['field_' . $field_id . '_visibility'] ) ) { 94 $visibility_level = $_POST['field_' . $field_id . '_visibility']; 95 } 96 97 xprofile_set_field_visibility_level( $field_id, bp_displayed_user_id(), $visibility_level ); 98 } 99 } 100 101 /** Other *****************************************************************/ 102 103 do_action( 'bp_xprofile_settings_after_save' ); 104 105 // Redirect to the root domain 106 bp_core_redirect( bp_displayed_user_domain() . bp_get_settings_slug() . '/privacy' ); 107 } 108 add_action( 'bp_actions', 'bp_xprofile_action_settings' );
Note: See TracChangeset
for help on using the changeset viewer.