$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>multisite - Add radio button on theme at the select of the theme the same theme should be activated after generation of new site|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

multisite - Add radio button on theme at the select of the theme the same theme should be activated after generation of new site

matteradmin11PV0评论

In my new multi-site project I need to show the theme option before user sign up I have shown the screen short of theme by using the below code.

$themes = wp_get_themes(); foreach( $themes as $theme ){ echo 'Theme Name: '.$theme -> name; echo 'get_screenshot()).'" /> '; }

Now what I need to do is to show the check box once user will select the check box or radio button so after the select of radio button the new site is generated by the user will activate the same theme that he select.

Also how I can show the only selected theme not all theme. Also with that user can preview all pages of theme before sign up. If some one now this please reply. if explain with the code much appreciated. Thanks

In my new multi-site project I need to show the theme option before user sign up I have shown the screen short of theme by using the below code.

$themes = wp_get_themes(); foreach( $themes as $theme ){ echo 'Theme Name: '.$theme -> name; echo 'get_screenshot()).'" /> '; }

Now what I need to do is to show the check box once user will select the check box or radio button so after the select of radio button the new site is generated by the user will activate the same theme that he select.

Also how I can show the only selected theme not all theme. Also with that user can preview all pages of theme before sign up. If some one now this please reply. if explain with the code much appreciated. Thanks

Share Improve this question asked Oct 19, 2018 at 5:28 user152482user152482 164 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Please paste the below code in the function.php file to activate the theme from front end

/** * 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 'Choose template for your site'; foreach ($themes as $theme){ echo 'get_screenshot().'" width="240"/>'; echo $theme->name . ' template.'" name="template" />'; } echo ''; }

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']); }

Post a comment

comment list (0)

  1. No comments so far