Forum Replies Created
- AuthorPosts
jennis015
ParticipantHI Ally. Thanks this code works!
*Could the delay just be down to the browser uploading the image?
the delay that i detect is caused by the button of image. You can see, the times between page and page with 0 button, 1 button o more buttons.
I look forward to this functionality (muitiple previews) in your great plugin!
Thank you!Attachments:
You must be logged in to view attached files.jennis015
ParticipantThanks Ally!! excellent!
jennis015
ParticipantThanks Ally! Regards!
jennis015
ParticipantHi Ally
I’m closer .. it works to create the user with his role. My difficulty is to add xprofile for this user. Could you help me?
add_action('quform_post_process_7','register', 10, 2); function register ($result, $form) { $username = $form->getValueText( 'quform_7_6' ); $email = $form->getValueText( 'quform_7_6' ); $password = $form->getValueText( 'quform_7_7' ); $role = 'shop_manager'; $userId = wp_insert_user(array( 'user_login' => $username, 'user_pass' => $password, 'user_email' => $email, 'role' => $role, )); $hash = wp_hash_password($password); update_user_meta( $user_id, '_is_shop_manager', 1 ); update_user_meta($userId, 'nickname', $form->getValueText('quform_7_28')); update_user_meta($userId, 'first_name', $form->getValueText('quform_7_28')); if(!is_wp_error( $userId)){ wp_set_current_user( $userId); // set the current wp user wp_set_auth_cookie( $userId); // startthe cookie for the current registered user if (bp_is_active('xprofile')) { if (!empty($usermeta['1,43,44'])) { $profile_field_ids = explode(',', $usermeta['1,43,44']); foreach ((array) $profile_field_ids as $field_id) { if (empty($usermeta["field_1"])) { $usermeta = array( 'field_1' => $form->getValueText('quform_7_28'), 'field_43' => $form->getValueText( 'quform_7_6' ), 'field_44' => $form->getValueText('quform_7_20'), ); } $current_field = $usermeta["field_1"]; xprofile_set_field_data($field_id, $user_id, $current_field); } } }} return $result; }
jennis015
ParticipantSorry i forget to told you that im using the plugin of BuddyPress to WordPress Full Sync,
jennis015
ParticipantHI Ally
I have working a long time with this:
I cant use easily bp_core_activated_user because i have desactived the activaction for autologin after complete the form ..so these code begin works: it create a new user like *shop_manager* (this rol isnt for default)
the problem is add the fields of xprofile to the user, this way dont work, do you have a better idea?
Thanks very much!
add_filter('quform_element_valid_7_6', function ($valid, $value, Quform_Element_Field $element) { if (username_exists($value)) { $element->addError('El nombre de usuario no esta disponible'); $valid = false; } return $valid; }, 10, 3); add_filter('quform_element_valid_7_6', function ($valid, $value, Quform_Element_Field $element) { if (email_exists($value)) { $element->addError('El correo ya ha sido registrado'); $valid = false; } return $valid; }, 10, 3); add_action('quform_post_process_7', function (array $result, Quform_Form $form) { $username = $form->getValueText( 'quform_7_6' ); $email = $form->getValueText( 'quform_7_6' ); $password = $form->getValueText( 'quform_7_7' ); $role = 'shop_manager'; $userId = wp_insert_user(array( 'user_login' => $username, 'user_pass' => $password, 'user_email' => $email, 'role' => $role, )); update_user_meta( $user_id, '_is_shop_manager', 1 ); return $result; }, 10, 2); function something_updated_profile() { global $current_user; get_currentuserinfo(); $user = get_userdata( $user_id ); $is_shopmanager = get_user_meta( $user_id, '_is_shop_manager', true ); if ( $is_shopmanager ) { // XProfile fields $usermeta = array( 'field_1' => $form->getValueText('quform_7_28'), 'field_43' => $form->getValueText( 'quform_7_6' ), 'field_44' => $form->getValueText('quform_7_20'), 'field_62' => $form->getValueText('quform_7_14'), 'field_64' => $form->getValueText('quform_7_11'), 'field_59' => 'Inmobiliaria', 'field_99' => $form->getValueText('quform_7_23'), 'field_103' => $form->getValueText('quform_7_41'), 'field_104' => $form->getValueText('quform_7_42'), 'field_105' => $form->getValueText('quform_7_40'), 'field_106' => $form->getValueText('quform_7_46'), 'field_107'=> $form->getValueText('quform_7_43'), 'field_108' => $form->getValueText('quform_7_44'), 'field_109' => $form->getValueText('quform_7_45'), 'field_110' => $form->getValueText('quform_7_47'), 'field_111' => $form->getValueText('quform_7_48'), ); $usermeta['profile_field_ids'] = '1,43,44,46,48,47,49,50,51,59'; $usermeta['password'] = wp_hash_password($password); }} add_action('xprofile_updated_profile', 'something_updated_profile', 1, 3);
jennis015
ParticipantHi Ally.
the suggested code did not work for checkbox, it appears empty, only appear the option the default option. (ex custom) it only works with a text box, but i can edit later.
Example in edit field:
:a:5:{i:0;s:15:”Río de Janeiro”;i:1;s:25:”Estado de Río de Janeiro”;i:2;s:6:”Brasil”;i:3;s:9:”Eindhoven”;i:4;s:13:”Países Bajos”;}
In the frontend:
Río de Janeiro, Estado de Río de Janeiro, Brasil, Eindhoven, Países Bajosmay be i should create a Repeater Fields field in xprofile? Could the information be imported as well?
On the other hand, how to determine the user’s role in the registry, i tried this but it didn t work, because I generated the profile with role *shop_manager* but it does nt imporport the xprofiles, any suggestions?
add_action('quform_post_process_7', function (array $result, Quform_Form $form) { if (function_exists('bp_core_signup_user')) { $username = $form->getValueText('quform_7_6'); $email = $form->getValueText('quform_7_6'); $password = $form->getValueText('quform_7_7'); // XProfile fields $usermeta = array( 'field_1' => $form->getValueText('quform_7_10'), 'field_43' => $form->getValueText('quform_7_6'), 'field_44' => $form->getValueText('quform_7_20'), ); $usermeta['profile_field_ids'] = '1,43,44'; $usermeta['password'] = wp_hash_password($password); $new_user = bp_core_signup_user($username, $password,$usermeta, $user_data->email, array()); $data = array('ID' => $new_user, 'role' => 'shop_manager', ); wp_update_user($data); update_user_meta( $user->ID, 'test', $usermeta ); } return $result; }, 10, 2);
Thanks very much! regards,
jennis015
ParticipantHi Ally, i was trying for hours, do you know how i can export multiple fields to xprofile like multiple fields?
because, in a text field it appears like array ( new york, paris) and when i use multiple option dont works.‘field_87’ => $form->getValueText(‘quform_7_23’),
any suggests?
Thanks!!jennis015
ParticipantHi Ally! thanks very much this works perfect!
jennis015
ParticipantHi Ally I forgot to clarify that I was referring to a Multiselect enhanced., Thanks!
jennis015
ParticipantSolved thanks! i recommend Orion OTP works good with Quform!
November 14, 2019 at 10:28 am in reply to: automatically activate and login user after register #30226jennis015
ParticipantSolved!! thanks!
November 13, 2019 at 1:43 am in reply to: automatically activate and login user after register #30225jennis015
ParticipantHi ally
i added this after the code of registration:add_filter('quform_post_process_5', function (array $result, Quform_Form $form) { wp_signon(array( 'user_login' => $username, 'user_password' => $password, 'remember' => true ), false); return $result; }, 10, 2);
but itsnt works. something is wrong? thanks!
jennis015
ParticipantHi yes the plugin is Orion OTP.
Quform It integrates well with the simple version but with multiform recognize the following button as sendjennis015
ParticipantThanks Ally! It works i change this line $(this).closest(‘.quform-page-5_1’).hide(); and the condition of the page for* hide if the element id 4-1 is not empty*.
Regards!- AuthorPosts