I am working on a job listing site and wants users to be able to apply for jobs on the site. I created 2 content types "Job posting" and "Job Application".

I used the nodereference_url module to add an apply now link on the job posting node that directs the user to the "job Application" form. This works fine but i would like to make each user to be able to apply for a particular job only once.

Is there a way i can achieve this with my current setup? Is there a different way to go about this that will give me the desired result?

Thank you for the help

  • 1
    It is a good idea to make the title of your question something that relates to the question itself otherwise it's harder to get answers. For example this question might have title something like "How can I hide a nodereference url link for users who have already created a node". Then people who know things about nodereference url, link hiding, etc. will be more likely to click into your question and possible answer it. The current title of this question is completely unrelated to the actual question so you will likely get less interest from the right people.
    – rooby
    Commented Sep 13, 2014 at 7:16

1 Answer 1


One solution that comes to mind includes using the nodereference_url_create_link function that is included in the Node Reference URL Widget module. From the documentation of the specific function:

 * Helper function for themers to easily create a link.
 * This function should be used in custom themes, rather than making manual
 * links because it first checks a user's access before showing the link. If
 * the user does not have access to create the node then an empty string will
 * be returned.
 * @param $node
 *   The node object that will be referenced.
 * @param $field_name
 *   The name of the Node Reference field.
 * @param $type_name
 *   The name of node type that contains the Node Reference field.
 * @param $attributes
 *   Optional. An array of additional attributes to add to the link.

You can use this in the node.tpl.php file for the Job Posting content type (which should be along the lines of node--job_posting.tpl.php if you're in D7 or node-job_posting.tpl.php for D6). The outline of the process should be as described below:

  • Hide the field at the top of your template file (you will render it later on if the user did not apply for the specific job).
  • Check if the user has already created an application node that references to the current posting.

The first step can be easily implemented by writing something along the lines of:


at the top of your template file. Use a dpm($content); first to make sure that you are hiding the right field.

The second step is a bit trickier. The most elegant way that comes to mind is to use the Corresponding Node References module so that when you create a reference from the application to the posting, a corresponding reference from the posting to the application is also created (this can also be useful if you want to show all the applications that were created for a specific posting in the posting's page).

After you have "linked" the posting and the application with CNR, all you need to do is check if the author of the other postings is the logged in user. Specifically, you can use the node reference array in the $node object to get the referencing applications with node_load_multiple and then with a foreach loop compare each $node->uid against the uid of the logged in user.

There is a blog post in Drutácora that describes a similar process and includes relevant code snippets (it's not in English but you should get the basic idea from the code).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.