• Resolved Yordan Soares

    (@yordansoares)


    I’m using ?User Registration? in a site that have several custom fields for users. I need to include some of these fields in the registration form. I dragged and drop a text field and add the custom field name ‘user_phone’, that is the user meta I’m using in one my custom fields.

    The issue here is that ?User Registration? add a prefix with ‘user_registration_{$field_name}’, in my case the final name of field was ‘user_registration_user_phone’. Is there a way to disable or override this prefix with an empty string to connect the form field with the one I created?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @yordansoares,

    Sorry, but it’s not possible to remove prefix unless you change to code in our plugin. But we do not recommend this approach. As we constantly update our plugins for better improvements.

    If possible, can you use the user metadata including the user_registration_ prefix?

    Regards!

    Thread Starter Yordan Soares

    (@yordansoares)

    Hi @rumesh38,

    I thought to do that, but I don’t wanted to have duplicate row in database. I wrote a solution without touch the plugin code, I used the action hook ‘user_registration_after_register_user_action’ that “User Registration” has built-in:

    
    /**
     * USER REGISTRATION / Save data in Custom Field
     * This function allow to save the data of a field from "User Registration" form
     * to a custom field you already have in your site and then delete the database row
     * that "User Registration" created to avoid duplicate rows. Following the same workflow,
     * you can setup all the fields you need.
     */
    
     // Preparing the function to trigger when user registrate throught "User Registration" form
    function mytheme_update_fields_from_user_registration( $form_data, $form_id, $user_id) {
      // Check the ID of Form to trigger the code for a particular form
      // You can get the ID from shortcode: [user_registration_form id="150"]
      if($form_id == 150) {
        // Get data from 'user_registration_user_phone' field just created
        $user_phone = get_user_meta($user_id, 'user_registration_user_phone', true);
        // Update our custom field from "User Registration" field
        update_user_meta($user_id, 'user_phone', $user_phone);
        // Delete the data of "User Registration" field
        delete_user_meta($user_id, 'user_registration_user_phone');
      }
    }
    // Trigger the function when a user registrate throught "User Registration" form
    add_action( 'user_registration_after_register_user_action', 'mytheme_update_fields_from_user_registration', 10, 3 );
    

    Cheers!

    EDIT: This code should be save in function.php or even better in a custom plugin. ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘About database prefix’ is closed to new replies.