Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'user_profile_update_errors', 'validate_sports_data' );
- function validate_sports_data(&$errors, $update = null, &$user = null)
- {
- foreach ($_POST['sport'] as $sport) {
- if (is_array($sport)) {
- foreach ($sport as $name) {
- if (empty($name)) {
- $errors->add('empty_person_name', "<strong>ERROR</strong>: Name of the player is empty,Please fill the name of the player.");
- }
- else {
- if (!preg_match("/[A-Za-z]/", $name)) {
- $errors->add('splchar_person_name', "<strong>ERROR</strong>: Name of the player should contain only alpahbets.");
- }
- }
- }
- }
- }
- }
- /* Update team details for user when saving his own profile */
- add_action( 'personal_options_update', 'update_user_teams' );
- /* Update team details for admin when saving other users team details */
- add_action( 'edit_user_profile_update', 'update_user_teams' );
- /* updating team details callback function */
- function update_user_teams( $user_id ) {
- if ( current_user_can( 'edit_user', $user_id ) ) {
- global $wpdb;
- global $projectmanager;
- $dataset_meta = $_POST['sport'];
- if ($_POST['team_status'] == 'yes') {
- $project_title = 'Approved User Teams';
- $project_id = $wpdb->get_var($wpdb->prepare("SELECT (id) FROM {$wpdb->projectmanager_projects} WHERE (title) LIKE ('%s')", $project_title));
- $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->projectmanager_dataset} SET `project_id` = (%d) WHERE (user_id) = (%d)", $project_id, $user_id ) );
- }
- else if ($_POST['team_status'] == 'no') {
- $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->projectmanager_datasetmeta} SET `value` = ('%s') WHERE (dataset_id) = (%d)", maybe_serialize($dataset_meta), $_POST['datasetId'] ) );
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement