Jump to content

Use AnnouncmentsAdd hook to not require the publish box to be checked


Recommended Posts

14 hours ago, hanstavo said:

Is it possible to use a hook to make the published checkbox when adding announcements auto checked or not required... If its not checked then the announcement will still be published.

to auto-tick the "Published" checkbox on NEW announcements only, you can use the following hook...

<?php

# Auto-Tick Published Checkbox on New Announcements Hook
# Written by brian!

add_hook('AdminAreaHeadOutput', 1, function($vars) {
	$id = intval($_GET['id']);
	if (!$id) {
		return <<<HTML
<script>
$(document).ready(function() {
$( "input[name$='published']" ).prop('checked', true);
});
</script> 
HTML;
}
});

 

Link to comment
Share on other sites

43 minutes ago, brian! said:

to auto-tick the "Published" checkbox on NEW announcements only, you can use the following hook...


<?php

# Auto-Tick Published Checkbox on New Announcements Hook
# Written by brian!

add_hook('AdminAreaHeadOutput', 1, function($vars) {
	$id = intval($_GET['id']);
	if (!$id) {
		return <<<HTML
<script>
$(document).ready(function() {
$( "input[name$='published']" ).prop('checked', true);
});
</script> 
HTML;
}
});

 

Thank You! I will try and let you know.

Link to comment
Share on other sites

54 minutes ago, brian! said:

to auto-tick the "Published" checkbox on NEW announcements only, you can use the following hook...


<?php

# Auto-Tick Published Checkbox on New Announcements Hook
# Written by brian!

add_hook('AdminAreaHeadOutput', 1, function($vars) {
	$id = intval($_GET['id']);
	if (!$id) {
		return <<<HTML
<script>
$(document).ready(function() {
$( "input[name$='published']" ).prop('checked', true);
});
</script> 
HTML;
}
});

 

Thank You! It worked!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated