Title: Limit for Custom Post
Last modified: August 22, 2016

---

# Limit for Custom Post

 *  anonymized-13603639
 * (@anonymized-13603639)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/limit-for-custom-post/)
 * Hello Guys.
 * I hope I can get a solution from you for the following issue:
    I use Polylang
   to get a multilingual web site. This works perfect. Additional I’ve created a
   custom post type with Polylang support. Works also very nice. And I use custom
   roles with capabilities to give a role the right to add a new custom post and
   save it. Everything works as expected.
 * Now, I would like to add a limit to allow the role to add only one post per language.
 * For this I wrote a function which checks how many languages are activated and
   how many posts in which language are already saved for the customer. One goal
   is to disable the “new post” button on the top of the list where WordPress shows
   all custom posts. The second goal is to disable or hide the “save” button on 
   the edit page.
 * Now, my questions are:
    1.) Where can I call the function to check the posts?
   Is there any hook (or some other place) which is called before WordPress shows
   the list of the custom posts?
 * 2.) How can I disable or switch off the “new post” at the top of this list? Important
   is, I have to do it without Java Script (jQuery) to prevent the user disables
   JS and can add an additional post.
 * 3.) How can I disable or hide the save button on the edit screen/dialog, also
   without jQuery?
 * Hope I made clear what I need and I hope more, you can give me a hint or the 
   solution 😉
 * Thanks a lot in advance!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/limit-for-custom-post/#post-5344054)
 * I’m afraid you will need to use javascript to disable those buttons, there is
   nothing to hook onto on the PHP side. That does not mean your enforcement mechanism
   can be circumvented. Sure they can cause the buttons to be enabled by disabling
   javascript. That allows them to inappropriately submit the form, but the server
   can easily disallow the submission regardless of what tricks they play on the
   browser side.
 * This still means you need your function to run. There is not a specific hook 
   for the post list table screen in general, but you could hook ‘admin_init’ and
   check what the request is for. If it’s not for pages you are concerned with, 
   return without doing anything.
 * You will not only want your function to run on the post list table screen, but
   also for the new post edit form and the POST of the actual completed post form.
   These last two would not need to be checked for if javascript could not be disabled,
   but since it can…
 *  Thread Starter anonymized-13603639
 * (@anonymized-13603639)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/limit-for-custom-post/#post-5344176)
 * Thank you, bcworkz, for your reply.
    You wrote
 * > but you could hook ‘admin_init’ and check what the request is for. If it’s 
   > not for pages you are concerned with, return without doing anything.
 * Im not very familiar with hooks, right now. I can use hooks but I have no idea
   which hook can help me with this issue.
    Is there a change for you giving me 
   an additional hint which hook I can use for it?
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/limit-for-custom-post/#post-5344196)
 * ‘admin_init’ is the action hook to use. You can use the contents of `$_SERVER`
   and `$_REQUEST` super globals to determine what’s being requested and if it is
   legitimate or not.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Limit for Custom Post’ is closed to new replies.

## Tags

 * [custom post](https://wordpress.org/support/topic-tag/custom-post/)
 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 3 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/limit-for-custom-post/#post-5344196)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
