Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 417 Vote(s) - 3.56 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WordPress: Custom Users not Appearing in Author box

#1
<br />
I've added a **custom user type** in Wordpress, the **custom post type** supports Authors(See below). The custom user type has all the privileges of an author except for 'publish posts', but is **not** on the list of possible authors to assign to the post.

What am I doing wrong?

Code:

if (!get_role('member')) {
add_role('member', 'SFUK Member', array(
'delete_posts' => true,
'edit_posts' => true,
'read' => true,
'upload_files' => true,
'edit_published_posts' => true,
'delete_published_posts' => true
));
}
and here is the custom post type :

$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => true,
'menu_position' => 0,
'supports' => array('title', 'editor', 'thumbnail', 'page-attributes', 'author')
);

if (!post_type_exists('ent')) {
register_post_type('ent', $args);
remove_post_type_support('ent', 'editor');

}

Let me know if more information is needed.
Reply

#2
The authors dropdown is created the following call:

wp_dropdown_users( array(
'who' => 'authors',
'name' => 'post_author_override',
'selected' => empty($post->ID) ? $user_ID : $post->post_author,
'include_selected' => true
) );
The `who` argument means that only users with at least 'author' role will be listed, and [the Codex page][1] says that currently it's either 'authors' or empty (meaning all users).
There is **a filter for this function** but it takes the HTML as input. You could create a new query for users and then output a new HTML dropdown. This is the first way to solve your problem.

However, this function with 'who' set to 'authors' searches for users whose level is not 0 which is quite strange since user levels have been deprecated long ago. I've found [a related bug report][2] on Trac recommending that you **add a 'level_1' capability** to your new role to fix this. This is not a clean solution but much easier than creating a filter and all HTML from scratch.

**EDIT**: A third and even more simple solution just came to my mind: I've created custom roles with plugins but never noticed this problem because I was always **copying capabilities from existing roles** and then modifying them. This way you won't forget any capabilities and it will also fix this bug.


[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through