Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
Wordpress muestra los botones Editar y Eliminar solo si el autor de la publicación

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?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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; }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!