Which User Role for Custom Post Type Menu – wp_nav
My first guess would be that he needs to make sure the checkbox is checked for that particular CPT under Screen Options (top right of Appearance -> Menus).
My first guess would be that he needs to make sure the checkbox is checked for that particular CPT under Screen Options (top right of Appearance -> Menus).
Below function works for me by adding !defined(‘DOING_AJAX’) in condition. function custom_blockusers_init() { if ( is_admin() && !defined(‘DOING_AJAX’) && ( current_user_can(‘usercrp’) || current_user_can(‘userpcp’) || current_user_can(‘subscriber’) || current_user_can(‘contributor’) || current_user_can(‘editor’))) { session_destroy(); wp_logout(); wp_redirect( home_url() ); exit; } } add_action( ‘init’, ‘custom_blockusers_init’ );
Adding multiple user roles dynamically
This had me baffled for a while as well. Not exactly a solution for your problem, but this should get you on your way. add_action( ‘admin_init’, ‘my_kses_remove_filters’ ); function my_kses_remove_filters() { $current_user = wp_get_current_user(); if ( my_user_has_role( ‘administrator’, $current_user ) ) kses_remove_filters(); } function my_user_has_role( $role=””, $user = null ) { $user = $user ? … Read more
Let us solve this by going with your second option. So you want to restrict users from editing published posts, this can be done by adding this to your theme’s functions.php file (please read the comments that is added): function restrict_editing_old_posts( $allcaps, $cap, $args ) { // Restrict users from editing post based on the … Read more
You can use get_queried_object to get data in the current author page: <?php $author = get_queried_object(); // uncomment next line to see all author data // print_r( $author ); if( in_array( ‘author’, $author->roles ) ) : echo “author”; elseif( in_array( ‘subscriber’, $author->roles ) ) : echo “subscriber”; endif;
The tags that are allowed in comments are stored in the $allowedtags global variable. You can try adding elements to that list (the key is the tag name, the value is an array of allowed attributes). If you have problems with the timing you can play with the CUSTOM_TAGS global variable.
filter login_redirect: function my_login_redirect_contributors() { if ( current_user_can(‘contributor’) ){ return ‘url-to-redirect-to’; } } add_filter(‘login_redirect’, ‘my_login_redirect_contributors’);
Editor and contributor roles not correct after adding function
You need to define something like this in your header.php file. <?php if ( is_user_logged_in() ) { echo ‘Welcome, registered user!’; } else { echo ‘Welcome, visitor!’; } ?> Create a new role with the following code and put it in your functions.php add_role(‘partners’, ‘Partners’, array( ‘read’ => true, // True allows that capability, False … Read more