Created
December 31, 2013 04:38
-
-
Save anonymous/8192689 to your computer and use it in GitHub Desktop.
This code should enable different user levels to add/ edit custom fields in the Wordpress. Solution to http://wpquestions.com/question/showChronoLoggedIn/id/9118
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'user_profile_update_errors', 'validate_field' ); | |
function validate_field(&$errors, $update = null, &$user = null) | |
{ | |
if($user->has_cap('s2member_level2')) { // Custom fields only display to business accounts | |
// Nested if to check for field(s) | |
if ($_POST['exp_years']=='' or $_POST['exp_years']==NULL) // Change to check for empty or any regular expression. | |
{ | |
$errors->add('empty_exp_years', "ERROR: Please select a valid value for exp years!"); | |
} | |
}else if($user->has_cap('s2member_level3')) { | |
// Do this | |
}else { | |
// Do that! | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solution for http://wpquestions.com/question/showLoggedIn/id/9118