Hide Fields
-
Hi,
I use PODS to add a Beauty Profile to my user’s comments through wpDiscuz. But no matter what i do, i can’t get the form to get any styling, and it shows fields like Display Name, E-Mail, and Password, which shouldn’t be there. It’s an extension to the user profile (Type User), but i actually have made quite some changes to get this going, but no matter what i do, the form can’t be styled and the fields won’t go away.
My Pod Template:<div class="beauty-profile-form">
<h2>Dein Beautyprofil</h2>
<form action="" method="post" class="pods-submittable pods-form pods-form-front pods-form-pod-user pods-submittable-ajax" id="pods-form-user-1">
<!-- Hidden fields for PODS form processing -->
<input name="action" type="hidden" value="pods_admin">
<input name="method" type="hidden" value="process_form">
<input name="do" type="hidden" value="save">
<input name="_pods_nonce" type="hidden" value="{@_pods_nonce}">
<input name="_pods_pod" type="hidden" value="user">
<input name="_pods_id" type="hidden" value="{@ID}">
<input name="_pods_uri" type="hidden" value="{@_pods_uri}">
<input name="_pods_form" type="hidden" value="alter,hauttyp_gesicht,hauttyp_koerper,haartyp,haarstruktur,haardicke,hautton,augenfarbe,hautprobleme">
<input name="_pods_location" type="hidden" value="{@_pods_location}">
<div class="beauty-section">
<h3>Hauttyp & Eigenschaften</h3>
{@alter}
{@hauttyp_gesicht}
{@hauttyp_koerper}
{@hautton}
{@hautprobleme}
</div>
<div class="beauty-section">
<h3>Haar & Augen</h3>
{@haartyp}
{@haarstruktur}
{@haardicke}
{@augenfarbe}
</div>
<div class="pods-submit">
<input type="submit" value="Profil aktualisieren" class="pods-submit-button">
</div>
</form>
</div>Additional CSS and JS:
<script>
jQuery(document).ready(function($) {
function styleBeautyProfile() {
$('.beauty-profile-form .pods-form-ui-field').addClass('beauty-styled-field');
$('.beauty-profile-form .pods-form-ui-field-type-pick').each(function() {
$(this).wrap('<div class="beauty-field"></div>');
});
$('.beauty-profile-form .description').each(function() {
$(this).insertAfter($(this).prev('.pods-form-ui-field'));
});
}
// Initial styling
styleBeautyProfile();
// Watch for dynamic content changes
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type === 'childList') {
styleBeautyProfile();
}
});
});
observer.observe(document.querySelector('.beauty-profile-form'), {
childList: true,
subtree: true
});
});
</script>
<style>
/* Reset and base styles */
.beauty-profile-form {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 30px;
background: #ffffff;
border-radius: 12px;
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
}
.beauty-profile-form h2 {
font-size: 24px;
color: #333;
text-align: center;
margin-bottom: 30px;
}
.beauty-section {
margin-bottom: 30px;
}
.beauty-section h3 {
font-size: 20px;
color: #444;
margin-bottom: 20px;
}
/* Field styles */
.beauty-profile-form .pods-form-ui-field-type-pick,
.beauty-profile-form select,
.beauty-profile-form input[type="text"],
.beauty-profile-form input[type="email"],
.beauty-profile-form input[type="password"] {
width: 100% !important;
padding: 12px !important;
border: 1px solid #ddd !important;
border-radius: 6px !important;
font-size: 15px !important;
background-color: #f9f9f9 !important;
transition: all 0.3s ease !important;
box-shadow: none !important;
height: auto !important;
line-height: 1.5 !important;
margin-bottom: 15px !important;
}
.beauty-profile-form .pods-form-ui-field-type-pick:focus,
.beauty-profile-form select:focus,
.beauty-profile-form input[type="text"]:focus,
.beauty-profile-form input[type="email"]:focus,
.beauty-profile-form input[type="password"]:focus {
border-color: #0073aa !important;
box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2) !important;
outline: none !important;
}
.beauty-profile-form .pods-form-ui-label {
display: block !important;
font-weight: 500 !important;
margin-bottom: 8px !important;
color: #333 !important;
}
.beauty-profile-form .description {
font-size: 13px !important;
color: #666 !important;
margin-top: 5px !important;
margin-bottom: 15px !important;
}
/* Checkbox styles */
.beauty-profile-form .pods-field.pods-boolean {
margin-bottom: 10px !important;
}
.beauty-profile-form .pods-field.pods-boolean label {
display: flex !important;
align-items: center !important;
font-weight: normal !important;
}
.beauty-profile-form .pods-field.pods-boolean input[type="checkbox"] {
margin-right: 8px !important;
}
/* Submit button */
.beauty-profile-form .beauty-button,
.beauty-profile-form input[type="submit"] {
background-color: #0073aa !important;
color: white !important;
border: none !important;
border-radius: 6px !important;
padding: 12px 24px !important;
font-size: 16px !important;
font-weight: 500 !important;
cursor: pointer !important;
transition: background-color 0.3s ease !important;
text-transform: none !important;
box-shadow: none !important;
height: auto !important;
line-height: 1.5 !important;
width: 100% !important;
margin-top: 20px !important;
}
.beauty-profile-form .beauty-button:hover,
.beauty-profile-form input[type="submit"]:hover {
background-color: #005a87 !important;
}
.beauty-profile-form .pods-form-ui-row-name-user_login,
.beauty-profile-form .pods-form-ui-row-name-user_nicename,
.beauty-profile-form .pods-form-ui-row-name-display_name,
.beauty-profile-form .pods-form-ui-row-name-user_pass,
.beauty-profile-form .pods-form-ui-row-name-user_email,
.beauty-profile-form .pods-form-ui-row-name-user_url {
display: none !important;
}
/* Responsive adjustments */
@media (max-width: 768px) {
.beauty-profile-form {
padding: 20px;
}
}
</style>Additional functions.php Snippet:
add_filter('pods_form_fields', 'filter_beauty_profile_fields', 10, 2);
function filter_beauty_profile_fields($fields, $pod) {
if ($pod->pod === 'user') {
$allowed_fields = array(
'alter', 'hauttyp_gesicht', 'hauttyp_koerper', 'haartyp',
'haarstruktur', 'haardicke', 'hautton', 'augenfarbe', 'hautprobleme'
);
foreach ($fields as $field_name => $field) {
if (!in_array($field_name, $allowed_fields)) {
unset($fields[$field_name]);
}
}
}
return $fields;
}
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Hide Fields’ is closed to new replies.