简体   繁体   中英

Custom WordPress Registration Page <select>

Basically I have a custom registration page which is being displayed on the front-end of my WordPress install, I'm using the Cimy User Extra Fields plugin to add a drop down <select> input to the form.

I need a way to manually hardcode this input directly in my registration page template.

If anyone has any idea on how to achieve this I would really appreciate it.
Cheers,
Tom.

This plugin lacks the frontend functions needed to display input elements. Don't try to look for the internal functions building the inputs, they are way too tied to WordPress admin internal code.

As a quick&dirty fix I basically copy-pasted the generated HTML from the administration form to my public page template. You'll notice that it prepends cimy_uef_ to field names. Then I used update_user_meta in a user_register hook and saved/added the value to wp_usermeta .

This goes into functions.php in your template or a custom plugin:

add_action('user_register', 'my_registration_save');

function my_registration_save($user_id) {

    if ( isset( $_POST['cimy_uef_some_field_name'] ) )
        update_user_meta($user_id, 'cimy_uef_some_field_name', $_POST['cimy_uef_some_field_name']);    
}

Next you'll have to add your input to the custom registration template and give it name="cimy_uef_some_field_name" . You can basically go to admin/users, click on one of them to get to the edit form and copy the HTML generated there by CIMY for the field you need.

Also have a look in the wp_usermeta table and see if it does or does not strip the cimy_uef_ prefix when saving fields, then change the second parameter in update_user_meta accordingly.

Decided to drop the plugin altogether, I didn't need it. I just followed this: https://wordpress.stackexchange.com/questions/50125/drop-down-list-in-user-profile-page

Thanks to anyone who tried to help. You are awesome.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM