Home Forums Event Espresso Premium Initialize Admin Questions

Initialize Admin Questions

Posted: January 20, 2023 at 2:58 am


January 20, 2023 at 2:58 am

I wrote a script, where I input a custom invoice number into the answer of a custom questions.

//After filtering the answer

It is working good with one exception. I would like to set the question as an admin question. But in this case it doesn’t work, because there is no answer (only visible for admin) and so I can’t set one.

If I set the question for the user and hide it through css, than I can’t use the custom questions in the message.

Is there a function to initialize the admin question so I can set a new value?


  • Support Staff

January 20, 2023 at 3:06 am

Can you post the code to a gist or Pastebin so I can see what you are doing? You can set it to be private so only EE staff can view the reply if preferred.


Your filtering all of the answers to find the specific answer to a specific question, which you already know the ID of, correct?

But if you already know the Question ID, why not just do it directly for that specific question?


January 23, 2023 at 9:29 am

The main problem is that the questions, that are set as “admin questions” in WordPress, don’t show up in the following query.
$answer_for_reg = EEM_Answer::instance()->get_one( array( array(
‘REG_ID’ => $reg_id ,
‘QST_ID’ => $qst_id_rechnungsbetrag
) ) );

Because the query is giving my an empty array I can’t use the set_value($new_value) method.


  • Support Staff

January 23, 2023 at 4:16 pm

The main problem is that the questions, that are set as “admin questions” in WordPress, don’t show up in the following query.

Ok, so that’s not actually correct.

Admin-only questions will not have answers generated for them on front-end registrations, because they are admin only questions and will only generate an answer when an admin has edited the registration.

So the reason the above query does not return an EE_Answer object, is there is no answer to generate yet.

Both $registrant->answers();

And EEM_Answer::instance()->get_one( array( array( 'REG_ID' => $reg_id , 'QST_ID' => $qst_id_rechnungsbetrag ) ) );

Will return an EE_Answer object for admin-only questions if there is something actually saved for those answers, on a front-end registration there will not have been anything saved.

You can confirm this yourself by editing one of those registrations and in the ‘Registration Form Answers’ section, edit the group with the admin-only question, don’t set a value and just hit ‘Update Registration Questions’, like this:

Now run either/both of the methods from above and you’ll have an extra EE_Answer object.


As you already know the QST_ID and the REG_ID, why not just generate the answer directly?

$new_answer = EE_Answer::new_instance(
        'QST_ID'    => $qst_id_rechnungsbetrag,
        'REG_ID'    => $reg_id,
        'ANS_value' => $new_value,

Obviously, do all of your own checks to confirm the question is actually an admin_only question and does not already have its own value (so you don’t overwrite a value set in the admin already) etc


January 24, 2023 at 5:14 am

Hey Tony,

that is exactly what I was looking for. Thank you for your help.


  • Support Staff

January 24, 2023 at 6:16 am

You’re most welcome

You must be logged in to reply to this support post. Sign In or Register for an Account

Event Espresso