Beispiel #1
0
/**
 * Handles the saving of xprofile field visibilities
 *
 * @since BuddyPress (1.9)
 */
function bp_xprofile_action_settings()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Bail if no submit action
    if (!isset($_POST['xprofile-settings-submit'])) {
        return;
    }
    // Bail if not in settings
    if (!bp_is_user_settings_profile()) {
        return;
    }
    // 404 if there are any additional action variables attached
    if (bp_action_variables()) {
        bp_do_404();
        return;
    }
    // Nonce check
    check_admin_referer('bp_xprofile_settings');
    do_action('bp_xprofile_settings_before_save');
    /** Save ******************************************************************/
    // Only save if there are field ID's being posted
    if (!empty($_POST['field_ids'])) {
        // Get the POST'ed field ID's
        $posted_field_ids = explode(',', $_POST['field_ids']);
        // Backward compatibility: a bug in BP 2.0 caused only a single
        // group's field IDs to be submitted. Look for values submitted
        // in the POST request that may not appear in 'field_ids', and
        // add them to the list of IDs to save.
        foreach ($_POST as $posted_key => $posted_value) {
            preg_match('/^field_([0-9]+)_visibility$/', $posted_key, $matches);
            if (!empty($matches[1]) && !in_array($matches[1], $posted_field_ids)) {
                $posted_field_ids[] = $matches[1];
            }
        }
        // Save the visibility settings
        foreach ($posted_field_ids as $field_id) {
            $visibility_level = 'public';
            if (!empty($_POST['field_' . $field_id . '_visibility'])) {
                $visibility_level = $_POST['field_' . $field_id . '_visibility'];
            }
            xprofile_set_field_visibility_level($field_id, bp_displayed_user_id(), $visibility_level);
        }
    }
    /** Other *****************************************************************/
    do_action('bp_xprofile_settings_after_save');
    // Redirect to the root domain
    bp_core_redirect(bp_displayed_user_domain() . bp_get_settings_slug() . '/profile');
}
/**
 * Handles the saving of xprofile field visibilities
 *
 * @since BuddyPress (1.9)
 */
function bp_xprofile_action_settings()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Bail if no submit action
    if (!isset($_POST['xprofile-settings-submit'])) {
        return;
    }
    // Bail if not in settings
    if (!bp_is_user_settings_profile()) {
        return;
    }
    // 404 if there are any additional action variables attached
    if (bp_action_variables()) {
        bp_do_404();
        return;
    }
    // Nonce check
    check_admin_referer('bp_xprofile_settings');
    do_action('bp_xprofile_settings_before_save');
    /** Save ******************************************************************/
    // Only save if there are field ID's being posted
    if (!empty($_POST['field_ids'])) {
        // Get the POST'ed field ID's
        $posted_field_ids = explode(',', $_POST['field_ids']);
        // Save the visibility settings
        foreach ($posted_field_ids as $field_id) {
            $visibility_level = 'public';
            if (!empty($_POST['field_' . $field_id . '_visibility'])) {
                $visibility_level = $_POST['field_' . $field_id . '_visibility'];
            }
            xprofile_set_field_visibility_level($field_id, bp_displayed_user_id(), $visibility_level);
        }
    }
    /** Other *****************************************************************/
    do_action('bp_xprofile_settings_after_save');
    // Redirect to the root domain
    bp_core_redirect(bp_displayed_user_domain() . bp_get_settings_slug() . '/profile');
}
 function bp_action_settings()
 {
     if (bp_is_user_settings_profile()) {
         bp_template_context(get_template_directory() . '/members/single/settings/profile.php');
     }
 }