Page 1 of 1

How To Hide Delete From Option?

Posted: Mon Dec 11, 2017 12:52 pm
by TahMiD
I need To Hide This Option For Logged in User, but How? Wanna Keep Edit, But Wanna Hide Delete. Plz Help mE!
Screenshot_9.png
Screenshot_9.png (143.6 KiB) Viewed 2841 times

Re: How To Hide Delete From Option?

Posted: Fri Dec 15, 2017 9:29 pm
by TahMiD
Hi There, Plz Reply on this topic.

Re: How To Hide Delete From Option?

Posted: Sun Dec 17, 2017 9:48 pm
by admin
Hi,
Sorry, my notification about the topic was hidden.

Open /template-parts/content-actions.php file and replace everything (leave the PHP comments) with this code:
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

if ( !current_user_can( 'editor' ) && !current_user_can( 'administrator' ) ) {
	return '';
} ?>

<button id="post-actions<?php the_ID(); ?>" class="post-actions mdl-button mdl-js-button mdl-button--icon">
	<i class="material-icons">more_vert</i>
</button>

<ul class="post-actions-menu mdl-menu mdl-menu--top-right mdl-js-menu mdl-js-ripple-effect" for="post-actions<?php the_ID(); ?>">

	<?php edit_post_link( esc_html__( 'Edit', 'realistic' ), '<li class="mdl-menu__item">', '</li>'); ?>

	<?php if ( current_user_can( 'administrator' ) ) {

		$delLink = wp_nonce_url( admin_url() . "post.php?post=" . get_the_ID() . "&action=delete", 'delete-' . get_post_type() . '_' . get_the_ID() ); ?>

		<li class="mdl-menu__item">
			<a href="<?php echo $delLink; ?>"><?php esc_html_e( 'Delete', 'realistic' ); ?></a>
		</li>

	<?php } ?>
</ul>
The 3dots buttons and menu will appear for editors and admins only but the delete link will appear for admins only.

I should be releasing a minor update with the new date code and this fix (maybe I will add the option to choose between theme Ago date format or WordPress default format. Expect version 1.3.2 to be rolling out in the coming few hours. Maybe you should start using a child theme or you will have to restore your modifications each time you update the theme.

Re: How To Hide Delete From Option?

Posted: Sun Dec 17, 2017 9:55 pm
by TahMiD
But I already made lots of changes, all will be lost... :?

Re: How To Hide Delete From Option?

Posted: Sun Dec 17, 2017 10:06 pm
by admin
The changes are not hard to export to a child theme.
I have created a blanc child theme for you. All you need to do is copy CSS code to your child theme style.css and functions.php custom code to your child theme functions.php file. Then copy every file you have modified to your child theme while keeping same folder hierarchy so for example, parent theme /template-parts/content.php file, if modified, must be copied to your child theme /template-parts/ folder.

Re: How To Hide Delete From Option?

Posted: Sun Dec 17, 2017 10:15 pm
by TahMiD
Where is the child theme?

Re: How To Hide Delete From Option?

Posted: Thu Dec 21, 2017 9:58 pm
by admin
TahMiD wrote:Where is the child theme?
Sorry :oops: I forgot to upload it. This happens to me a lot :D
realistic-child.21.12.2017.zip
(2.1 KiB) Downloaded 89 times

Re: How To Hide Delete From Option?

Posted: Thu Dec 21, 2017 10:27 pm
by TahMiD
No problem, I am Downloading It Now. And Can't Wait For The Pro Version Of This Theme. Just Love Google material Design!

Re: How To Hide Delete From Option?

Posted: Thu Dec 21, 2017 10:35 pm
by admin
Good! I am afraid it will take a while before I will be able to start working on the Material Design theme but I promise you it will worth the waiting.

Happy new year my friend :D

Re: How To Hide Delete From Option?

Posted: Thu Dec 21, 2017 10:39 pm
by TahMiD
yep. Happy new year brother!