Home › Forums › Plugin Support › Fields required on front-end but NOT back-end?
Tagged: registration, required, required fields
- This topic has 5 replies, 4 voices, and was last updated 13 years ago by
Support.
-
AuthorPosts
-
September 14, 2012 at 6:22 am #2086September 15, 2012 at 2:35 am #2090
toddz70
MemberI solved this for myself with some custom jQuery, added to the wp-admin.
In FUNCTIONS.PHP ….
function my_script() {
if(is_admin()){
wp_enqueue_script('custom_admin_script', get_bloginfo('template_url').'/js/admin.js', array('jquery'));
}
}
my_script();
in JS/ADMIN.JS …..
jQuery(document).ready(function(){
jQuery('input.um_input').each(function() {
var class_text;
class_text = jQuery(this).attr("class");
class_text = class_text.replace("validate[required]","");
class_text = class_text.replace("validate[required,","validate[");
//console.log(class_text); //test
jQuery(this).attr("class",class_text);
});
});
It’d be great if this were implemented as built-in feature of the plugin though.. as another checkbox in each Field, so the user can set whether the field is required in Admin too, or just front-end.
September 17, 2012 at 3:15 pm #2100Khaled
MemberHello, you can create two fields with same meta_key(different title if you need) and use one in front-end form with required checkbox=true and another in back-end profile with required checkbox=false
Thanks.
August 2, 2013 at 9:36 pm #4046jellycode
MemberThis is an excellent answer to this problem and exactly what I was looking for.
Like the OP, I think it would be great if this code was implemented as a built-in feature.August 6, 2013 at 6:08 am #4052toddz70
MemberUsing separate fields for front-end and back-end would be very hard to manage. My site already has 30 fields, so i’d need 60?
Please just implement this as another checkbox within each Field. It’d be so much easier to manage.
August 7, 2013 at 5:19 am #4057Support
MemberPerhaps, those code might better suit for your (in functions.php)
add_filter( 'user_meta_field_config', 'user_meta_field_config_function', 10, 3 ); function user_meta_field_config_function( $field, $fieldID, $formName ){ global $userMeta; // Check if current user has admin role and viewing from admin panel if( $userMeta->isAdmin() && is_admin() ){ unset( $field['required'] ); } return $field; } -
AuthorPosts
- You must be logged in to reply to this topic.
