Restricting the indexing to particular user roles ?
-
Hello, I found this code on the official website of Relevanssi, but it’s doesn’t seem to work anymore.
add_filter( 'relevanssi_user_index_ok', 'rlv_do_not_index_admins', 10, 2 ); function rlv_do_not_index_admins( $do_index, $user ) { $block_these_roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); $vars = get_object_vars( $user ); if ( is_array( $vars['caps'] ) ) { foreach ( array_keys( $vars['caps'] ) as $role ) { if ( in_array( $role, $block_these_roles, true ) ) { $do_index = false; break; } } } return $do_index; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Restricting the indexing to particular user roles ?’ is closed to new replies.