admin管理员组文章数量:1130349
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 badges1 Answer
Reset to default 0Please 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']); }
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 badges1 Answer
Reset to default 0Please 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']); }
本文标签:
版权声明:本文标题:multisite - Add radio button on theme at the select of the theme the same theme should be activated after generation of new site 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749236622a2337382.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论