I've created a form on the front-end on my site to allow registered members to post posts without needing access to the Admin CP however I'd like to hide a specific form element from the output.
The element we'd like to hide is a tickbox that allows an item to be featured which only the admins should be able to see. Is this possible using the automated form output? I've used the following safecracker code:
{global_errors}{error}{/global_errors}
<label for="title">Title</label>
<input type="text" name="title" id="title" value="{title}" size="50" maxlength="100" onkeyup="liveUrlTitle();">
{status_menu}
<label for="status">Status</label>
<select name="status" id="status">
{select_options}
</select>
{/status_menu}
{custom_fields}
<p><label for="{field_name}">{if required}* {/if}{field_label}</label>
{field_instructions}
{formatting_buttons}
{if error}
<span class="error">{error}</span>
{/if}
{if textarea}
<textarea id="{field_name}" name="{field_name}" dir="{text_direction}" rows="{rows}">{field_data}</textarea>
{/if}
{if text}
<input type="text" dir="{text_direction}" id="{field_name}" name="{field_name}" value="{field_data}" maxlength="{maxlength}" size="50">
{/if}
{if select}
<select id="{field_name}" name="{field_name}">
{options}<option value="{option_value}"{selected}>{option_name}</option>{/options}
</select>
{/if}
{if date}
<input type="text" id="{field_name}" name="{field_name}" value="{field_data}" size="50">
{/if}
{if checkbox}
{options}
<label class="checkbox">{option_value}
<input type="checkbox" id="{field_name}" name="{field_name}[]" value="{option_value}"{checked}>
</label>
{/options}
{/if}
{if radio}
{options}
<label class="checkbox">{option_value}
<input type="radio" id="{field_name}" name="{field_name}" value="{option_value}" {checked}>
</label>
{/options}
{/if}
{if safecracker_file}
{display_field}
{/if}
{if relationship}
<select id="{field_name}" name="{field_name}">
{options}
<option value="{option_value}"{selected}>{option_name}</option>
{/options}
</select>
{/if}
{if multiselect}
<select id="{field_name}" name="{field_name}[]" multiple="multiple">
{options}
<option value="{option_value}"{selected}>{option_name}</option>
{/options}
</select>
{/if}
{if rte}
<textarea id="{field_name}" class="rte" name="{field_name}" dir="{text_direction}" rows="{rows}">{field_data}</textarea>
{/if}
</p>
{/custom_fields}
<input type="submit" name="submit" value="Submit">
You could lose the {custom_fields}
loop and hardcode all the fields.
Or you could expand on @unexplainedBacn's plan and add a test for field_name
as well as member_group
-- otherwise you're hiding all checkboxes.
{if checkbox}
{if field_name == 'field_to_hide' && logged_in_group_id == 1}
{options}
<label class="checkbox">{option_value}
<input type="checkbox" id="{field_name}" name="{field_name}[]" value="{option_value}"{checked}>
</label>
{/options}
{if:elseif field_name != 'field_to_hide'}
{options}
<label class="checkbox">{option_value}
<input type="checkbox" id="{field_name}" name="{field_name}[]" value="{option_value}"{checked}>
</label>
{/options}
{/if}
{/if}