Support

Home Forums Event Espresso Premium display some custom question in default wordpress registration form

display some custom question in default wordpress registration form

Posted: December 5, 2017 at 4:36 am

Viewing 14 reply threads


inside

December 5, 2017 at 4:36 am

Hi there,
Just a quick question to see if there is any possibility to add a System Question in the EE4 Registration Form.
Because I need to display some custom question in the wordpress registration form (website registration form not event registration form)
Many thanks in advance


Tony

  • Support Staff

December 5, 2017 at 4:46 am

Hi there,

We don’t have any plans to add in your own system questions into EE, but you can add custom questions to any group in EE so there’s no need.

However, I’m not sure I understand how adding a system question helps add a question to the WP Registration form?

Can you provide more details on what you are trying to do please?


inside

December 5, 2017 at 5:05 am

Hi Tony,
Thanks for your help.
I need to display custom question (from the Event Espresso – Registration Form) in the wordpress register form(http://example/wp-login.php?action=register)
Is it possible?


Tony

  • Support Staff

December 5, 2017 at 5:22 am

No, that’s not possible.

The questions system only runs within EE and the questions are assigned to a registration, at the link you provided above you don’t have an active registration so there’s nothing to link the question to.


inside

December 5, 2017 at 5:51 am

So Is it possible to make synchronization between system user register fields and EE custom question?
The link that i provided is just an example
The right one is This


inside

December 6, 2017 at 12:25 am

http://take.ms/IMhzA


Tony

  • Support Staff

December 6, 2017 at 3:36 am

Yes, it’s possible.

You’ll find an example of this within the WP user Integration add-on, take a look in EED_WP_Users_SPCO.modules.php and the filter_answer_for_wpuser() method.

It uses the FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value filter which is passed the registration and question_id, you caan then check the question_id for your custom question and return the value from your user meta field.


inside

December 14, 2017 at 12:09 am

Tony, thank you so much for your assistance.
I have created new custom question (type text with id 18).
Then i have added the next code to filter_answer_for_wpuser() method:
.
.
.
.

if ( is_numeric( $question_id ) && defined( ‘EEM_Attendee::TXT_18’ ) ) {
//$emmergency = EEM_Attendee::TXT_18_question_id;
//$emmergency = system_question_TXT_18;
$emmergency = TXT_18_question_id;
$id_to_use = $question_id;
}
.
.
.
.

//var_dump($question_id);
var_dump($id_to_use);
if ( $current_user instanceof WP_User ) {
switch ( $id_to_use ) {
.
.
.
case $emmergency :
$value = $current_user->get( ‘EmergencyContactPerson’ ).” “;
break;

.
.
.

the output of var_dump($id_to_use); is:

string(5) “fname”
string(5) “lname”
string(0) “”
string(0) “”
string(5) “email”
string(0) “”
string(0) “”
string(0) “”
string(0) “”
string(0) “”
string(0) “”
string(0) “”
string(0) “”
string(0) “”
string(0) “”
string(0) “”
string(0) “”

Did I Miss Anything?


Tony

  • Support Staff

December 14, 2017 at 5:06 am

You don’t need to modify core files when the function uses a hook, you can add your own function to the same hook and add details that way.

However, I realized the above may not be the right hook for you to use so I put another example together:

https://gist.github.com/Pebblo/0abe11d85af126e0aa0db80b1772901b

That sets the default value of a custom question with an ID of 93 (you’ll likely need to use 18) and then pulls the value from user meta which it uses as the ‘default’ value for the question.

Is that what you are looking for?


inside

December 19, 2017 at 12:19 am

As always… you are the best Tony Warwick!
Thank you very much
It’s working perfectly well after adding two line in the begin of the function

global $current_user;
get_currentuserinfo();

Thank you I really appreciate your help.


Tony

  • Support Staff

December 19, 2017 at 2:18 am

You’re most welcome and oops, yeah I should have included that.

However get_currentuserinfo() has been deprecated since WP 4.5:

https://codex.wordpress.org/Function_Reference/get_currentuserinfo

You should use wp_get_current_user()

https://codex.wordpress.org/wp_get_current_user

Note, I’ve updated my gist with the above.


inside

December 27, 2017 at 10:50 pm

Hi Tony,

I face some problems with drop-down list. Can’t set the default value using

$input_args[ ‘default’ ] = $drop_down_select;


Tony

  • Support Staff

December 28, 2017 at 4:11 am

Hi there,

I need more info than that single line 🙂

Can you post the code you are using to PasteBin or create a gist and post the link here to view?


inside

December 28, 2017 at 5:22 am

case 17:
//Pull your custom value from user meta, be sure to change ‘user_meta_key’ to the meta key you used.
$nationality = get_user_meta($current_user->ID, ‘nationality’, true);
//Check we have a value.
if( $nationality ) {
//Set the default value of the question to your user_meta value.
$input_args[ ‘default’ ] = $nationality;
}
break;

The nationality is a Country Dropdown question


Tony

  • Support Staff

December 28, 2017 at 8:52 am

Yeah, you can’t set the default value of a drop-down that way and you’ll run into problems trying to set the default value of the EE Country dropdowns as they’ll need to match exactly what is set in EE for it to work.

I’d recommend switching to a text input.

Viewing 14 reply threads

The support post ‘display some custom question in default wordpress registration form’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso