Ich verwende wp_terms_checklist
, um Optionen anzuzeigen, mit denen ein Benutzer das Benutzerprofil einchecken kann. Dies funktioniert gut, wenn Sie als Admin angemeldet sind, aber wenn ich mich als Abonnent anmelden die Kontrollkästchen Eingänge haben disabled="disabled"
hinzugefügt.wp_terms_checklist Kontrollkästchen sind im Teilnehmerprofil deaktiviert
Ich würde nicht denken, dass dies ein Berechtigungsproblem ist, da der Inhalt tatsächlich auf der Profilseite des Abonnenten erscheint. Es scheint wahrscheinlich, dass es von dieser Funktion https://codex.wordpress.org/Function_Reference/disabled kommt, warum ich nicht weiß.
Hier ist der Code (Dies ist Teil einer benutzerdefinierten Plugin Ich bin zu machen):
<?php
add_action('show_user_profile', 'iw_notify_show_user_options');
add_action('edit_user_profile', 'iw_notify_show_user_options');
function iw_notify_show_user_options($user) { ?>
<h3 id="notifications">Notification Options</h3>
<style>
.iw_notify_heirarchical_list ul { padding-left:20px; }
</style>
<div class='iw_notify_heirarchical_list'>
<ul class=iw_notify_heirarchical_list>
<?php
$selected_cats = get_the_author_meta('tax_input', $user->ID);
$selected_cats = $selected_cats['notifications'];
if (!function_exists('wp_terms_checklist')) {
require_once ABSPATH . '/wp-admin/includes/template.php';
}
$post_id = -1;
$args = array(
'descendants_and_self' => 0,
'selected_cats' => array('165','164'),
'popular_cats' => false,
'walker' => '',
'taxonomy' => 'notifications',
'checked_ontop' => false
);
wp_terms_checklist($post_id, $args);
?>
</ul>
</div>
<?php }
add_action('personal_options_update', 'my_save_extra_profile_fields');
add_action('edit_user_profile_update', 'my_save_extra_profile_fields');
function my_save_extra_profile_fields($user_id) {
if (!current_user_can('read', $user_id))
return false;
update_usermeta($user_id, 'tax_input', $_POST['tax_input']);
}