wp_terms_checklist
を使用して、ユーザがユーザプロファイルをチェックインするオプションを表示しています。 の管理者としてログインしても問題ありませんが、のユーザとしてログインすると、チェックボックスの入力にはdisabled="disabled"
が追加されます。ユーザプロファイルでwp_terms_checklistチェックボックスが無効になっています
コンテンツがサブスクライバのプロファイルページに実際に表示されているため、これは権限の問題ではないと思います。それは、この関数から来る可能性が高いと思われる理由は、https://codex.wordpress.org/Function_Reference/disabledです。
あなたが正しい<?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']);
}