1

So, you can make "Preview before submitting" optional or required for a node type. I would like to make it optional based on the user who is creating the node.

So, for example, a authenticated user has to view the preview of a node before he can save it, whereas a administrator user can save the node without previewing it beforehand.

Is there a module for that?

I tried it myself, hiding the submit button in hook_form_alter, depending on the current user's role:

$form['actions']['submit']['#access'] = false;

But i can't let the submit button appear again in hook_node_validate by doing:

$form_state['complete form']['actions']['submit']['#access'] = true;

Any help would be appreciated!

0

You have to unset the button:

unset($form['actions']['submit']);

This will delete the submit button from the array, thus it won't show up. Be carefull bacause above code will hide your submit button. You will have to check the key for the "preview" button.

  • hiding the submit button in hook_form_alter isn't the problem. Making it reappear during the node preview is. – caspermc Oct 28 '14 at 15:41
  • I misunderstood you question. Try to add $form_state['rebuild'] = TRUE; – Robin Oct 29 '14 at 9:28
  • yes, that is making the submit button reappear. But that skips the preview of the node, jumps right back to the form. – caspermc Oct 29 '14 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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