So, I have code directly below for setting up inset array. Problem is with user_admin. I have a piece of a form I am not calling if their profile is being edited by themselves (as to not allow last admin to be removed from site) If I allow input to be called, everything works fine. If it is not called (while wrapped in if statement) and form is submitted, it always reverts user_admin to 0 (removes admin ability)
$data = array(
'user_id' => $_GET['user'],
'user_company' => $_POST['user_company'],
'user_role' => $_POST['user_role'],
'user_admin' => (($_POST['user_admin'] || $_GET['user_admin']) == '1') ? '1': '0',
);
and the part of the form
<?php // if (get_current_user_id() != $_GET['user']) : ?>
<div class="row">
<div class="col-xs-12">
<label>Member's Site Capabilities<span class="flaticon-questions1" data-toggle="tooltip" data-placement="top" title="Administrator allows changes to project settings and invitation/deletion of team members. It is recommended to have at least one architect administrator and one contractor administrator."></label>
</div>
<div class="col-xs-12">
<select name="user_admin" required>
<option value="0"<?php selected('0', $user->admin); ?>>Standard</option>
<option value="1"<?php selected('1', $user->admin); ?>>Site Administrator</option>
</select>
</div>
</div>
<?php // endif; ?>
Any suggestions on getting the admin to stick if its already set to something. I could hidden field it but don’t want to make it reachable.
Apologize if this is trivial, a bit of a neophyte here.
Thank you.
I think you could use the following instead of your code:
The
$_REQUEST
-array holds$_GET
and$_POST
values.Try to
var_dump($_REQUEST);
to see which values are stored in it.