Leave a Reply

4 comments

  1. In order to do what you want , you can add whatever fields you want, and then store them in the user_meta

    (One could also store them in the $user_info array/object, but I am not sure what would be the benefit .. )

      // Render Form Fields
    add_action('register_form','k99_register_form_add_theme_field');
    // Checking
    add_action('register_post','k99_check_fields',10,3);
    // Insert Data
    add_action('user_register', 'k99_register_new_register_fields');
    
    // Render the form with the additional radio field 
    function k99_register_form_add_theme_field(){
    ?>
    
    <p>
    <label>Theme<br />
     <?php $themes=wp_get_themes();
    foreach ($themes as $theme ) {
    $theme['Name'] = sanitize_title_with_dashes($theme['Name']);
    $checked = checked( $_POST['custom_theme'], 1 );
     echo '<input id="custom_theme'.$theme['Name'] .'" type="radio" name="custom_theme" value="'. $theme['Name'] .'" '.$checked.'>  '. $theme['Name'].'<br />';
    $custom_theme = $_POST['custom_theme'];
    } ?>
    </label>
    </p>
    
    <?php
    }
    
    // checking , sanitation etc .. of course this is not done...
    
    function k99_check_fields($login, $email, $errors) {
    global $custom_theme;
    if ($_POST['custom_theme'] == '') {
    $errors->add('empty_theme', "<strong>Error:</strong> Please select theme.");
    }
    else {
    $custom_theme = $_POST['custom_theme'];
    }
    }
    
    // Write to DB ... if you will..
    function k99_register_new_register_fields($user_id, $password="", $meta=array())  {
    
    $custom_theme = $_POST['custom_theme']; //just in case ..
    update_usermeta($user_id, 'user_custom_theme',$custom_theme);
    
    }
    

    after all of that you can retrieve the user_theme like so :

    get_user_meta($user_id, 'user_custom_theme', true);
    

    NOTE : This was written On-The-Fly. It was not verified on multi-blog, but on a simple wp installation , and although there should not be much difference – still this is not a production function, it was only to put you on the right track. Sanitation and checking on variables, cleaning code and FORM MARKUP are needed , as well as adding the field also to other user related screens (create user, edit user, edit profile etc..) .

    NOTE II: you asked about gravity forms in your uodate – they have an add-on for that

  2. This kind of answers your question:
    We put a plugin called ‘Theme Switch‘ on this site: focusww.com and it put a sidebar where you can choose from a list of themes. It lets you choose which themes may be used and how long before the cookie expires to revert to a default theme.

  3. If still relevant, maybe this could help others looking for similar solutions

    /**
     * Add custom field to registration form
     */
    add_action( 'signup_blogform', 'aoc_show_addtional_fields' );
    add_action( 'user_register', 'aoc_register_extra_fields' );
    
    function aoc_show_addtional_fields() 
    {
        $themes = wp_get_themes();
        echo '<label>Choose template for your site';
        foreach ($themes as $theme){
            echo '<img src="'.$theme->get_screenshot().'" width="240"/>';
            echo $theme->name . ' <input id="template" type="radio" tabindex="30" size="25" value="'.$theme->template.'" name="template" />';
        }
        echo '</label>';
    }
    
    function aoc_register_extra_fields ( $user_id, $password = "", $meta = array() ) {
        update_user_meta( $user_id, 'template', $_POST['template'] );
    }
    
    // The value submitted in our custom input field needs to be added to meta array as the user might not be created yet.
    add_filter('add_signup_meta', 'aoc_append_extra_field_as_meta');
    function aoc_append_extra_field_as_meta($meta) 
    {
        if(isset($_REQUEST['template'])) {
            $meta['template'] = $_REQUEST['template'];
        }
        return $meta;
    }
    
    // Once the new site added by registered user is created and activated by user after email verification, update the template selected by user in database.
    add_action('wpmu_new_blog', 'aoc_extra_field', 10, 6);
    function aoc_extra_field($blog_id, $user_id, $domain, $path, $site_id, $meta) 
    {
        update_blog_option($blog_id, 'template', $meta['template']);
        update_blog_option($blog_id, 'stylesheet', $meta['template']);
    }
    

    I have written a blog post (http://artofcoding.in/select-theme-while-registering-wordpress-multisite-network/) here when I had a similar requirement. Hope this is helpful.