Mi sitio de wordpress utiliza envíos de publicaciones (en realidad, CPT) de los miembros del sitio. Al mostrar la publicación de CPT, me gustaría que aparecieran botones para Editar y Eliminar cuando el autor está viendo la publicación, y que no aparezcan si algún otro miembro ve la publicación. He investigado el código y los complementos, pero todos parecen aplicarse solo al rol de autor, no al autor específico en sí. ¿Hay alguna manera de usar la función/código abreviado de PHP, Javascript o alguna combinación de los dos para agregar esta funcionalidad?
Aquí está el código para el botón de deshabilitar editar y eliminar. He probado el código y funciona bien por mi parte.
SOLO PARA EL ENLACE DEL BOTÓN EDITAR
function prefix_remove_get_edit_post_link( $link ) { global $post; $current_user = get_current_user_id(); $author_id = get_post_field ('post_author', $post_id); if($author_id == $current_user) { return $link; } return null; } add_filter('get_edit_post_link', 'prefix_remove_get_edit_post_link');SOLO PARA EL ENLACE DEL BOTÓN ELIMINAR
function prefix_remove_get_delete_post_link( $link ) { global $post; $current_user = get_current_user_id(); $author_id = get_post_field ('post_author', $post_id); if($author_id == $current_user) { return $link; } return null; } add_filter('get_delete_post_link', 'prefix_remove_get_delete_post_link');PARA LOS BOTONES OCULTAR EDITAR Y ELIMINAR
add_filter( 'post_row_actions', 'remove_row_actions', 10, 1 ); function remove_row_actions( $actions ) { global $post; $current_user = get_current_user_id(); $author_id = get_post_field ('post_author', $post_id); if($author_id != $current_user) { if( get_post_type() === 'post' ){ unset( $actions['edit'] ); unset( $actions['trash'] ); unset( $actions['inline hide-if-no-js'] ); } } return $actions; }