public function update_profile() { global $bc_accounts; if (!isset($_POST['_bc_profile_nonce'])) { return false; } if (!wp_verify_nonce($_POST['_bc_profile_nonce'], 'bc_profile_nonce')) { return false; } $hash = BC_Utility::sanitize_payload_item($_POST['bc-user-default-source']); $user_id = BC_Utility::sanitize_id($_POST['user_id']); $accounts = $bc_accounts->get_sanitized_all_accounts(); if (!isset($accounts[$hash])) { BC_Utility::admin_notice_messages(array(array('message' => esc_html__('The specified Source does not exist.', 'brightcove'), 'type' => 'error'))); return false; } BC_Utility::update_user_meta($user_id, '_brightcove_default_account_' . get_current_blog_id(), $hash); return true; }
public function set_account_details_for_user($hash, $user_id = false) { if (!$user_id) { $user_id = get_current_user_id(); } else { if (!current_user_can('brightcove_set_user_default_account')) { return false; // Permissions violation. } } $account = $this->get_account_by_hash($hash); if ($account) { BC_Utility::update_user_meta($user_id, '_brightcove_default_account_' . get_current_blog_id(), $hash); $this->current_account = $account; } }