最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

customization - I want to submit multiple users if checkbox is checked

programmeradmin0浏览0评论

The following code is getting all terms and see if any one of them is checked or not. If any term is checked a form should show under the selected checkbox with email, the username(auto-generated) and password(auto-generated), and admin should be available to submit each form which will create a user for a specific term.

The problem is The form is being submitted to options.php which I have to submit checkboxes in the options table

<div class="wrap">
            <?php screen_icon(); ?>
            <h2>Subdomain Settings</h2>           
            <form method="post" action="options.php">
            <?php
                // This prints out all hidden setting fields
                settings_fields( 'subdomain_option_group' );   
                do_settings_sections( 'subdomain-admin' );
                submit_button(); 
            ?>
            </form>
        </div>
        $selected = $this->options;
        $terms = $GLOBALS['wpdb']->get_results( "SELECT * FROM wp_terms", OBJECT );
//      $terms = get_terms();
//      echo plugin_dir_url( __FILE__ ) . 'subdomain-users.php';
        foreach($terms as $term) {
            ?><div class="wrap"> <?php
                ?> <input id="in-category-<?php echo $term->term_id ?>" type="checkbox" name="post_category[]" <?php echo in_array($term->term_id, $selected['subdomain_cat']) ? "checked" : ""; ?> value="<?php echo $term->term_id; ?>" > 
                <label for="in-category-<?php echo $term->term_id ?>"> <?php echo $term->name; ?></label>
                <?php
                if(in_array($term->term_id, $selected['subdomain_cat'])) {
                    ?> <div style="margin-bottom: 25px;"> <?php
                        ?> <form method="post" action=""><?php
                        ?> <h2><?php echo "Category : ".$term->name.'<br/>'; ?></h2> <?php
                        ?> <input type="email" placeholder="Enter Your Email:" name="email"> <?php
                        ?> <input required type="text" placeholder="Enter Your Name:" value="<?php echo $this->generate_user_name($term->name); ?>" name="name"> <?php
                        ?> <input required type="text" value="<?php echo $this->randomPassword() ?>" placeholder="Enter Your Password:" name="password"> <?php
                        ?> <input type="submit" name="user_save" id="user_save" class="button button-primary" value="Save User"><?php
                        ?> </form> <?php
                    ?> </div> <?php
                }
            ?></div><?php
            
        }

Please let me know how do I submit this form to create user for each term And I want to add a role and permission too which will allow the created user to select only the relevant term(category) for post and he will be author for only that category.

Thanks

发布评论

评论列表(0)

  1. 暂无评论