Support

Account

Home Forums Feature Requests Assign a typical Costum post to users as soon as they are created.

Unread

Assign a typical Costum post to users as soon as they are created.

    • Bonito

    • October 29, 2020 at 1:16 am

    Hello, I’m creating a planning system for users (roles = couples). To do this I have created a post type Planning where we and the users (roles = couples) will create tasks. It works very well. The tasks are displayed according to the user who created them.

    Here is the display code of the task:

    <div id="tab1" class="tab_content tache-content">
    
                    <?php
                    if (have_posts()) :
                        $args = array(
                            'post_type' => 'mon_planning',
                            'post_id' => true,
                            'posts_per_page' => -1,
                            'order' => 'ASC',
                            'author' => $user_id
    
                        );
                        $tache = new WP_Query($args);
                        ?>
                        <ul class="list-group list-planning">
                            <?php while ($tache->have_posts()) : $tache->the_post();
                                ?>
                                <?php
                                if (get_field('timming_tache') == 'De 10 à 12 mois') {
                                    ?>
    
                                    <a href="#" class="list-group-item list-group-item-action" data-toggle="modal" href="#"
                                       data-target="#tache-<?php echo get_the_ID(); ?>">
                                       <!-- <button type="button" class="delete" data-dismiss="modal"><i class="las fa-trash"></i></button>-->
                                        <?php the_title(); ?>
                                        <!--Cat tâche -->
                                        <br>
                            <span class="badge badge-pill badge-warning"
                                  style="background: #efefef; color: #8c8c8c; ;padding: 5px 10px; font-weight: 500;"><?php the_field('categorie_de_tache'); echo get_the_ID(); ?></span>
                                    </a>
                                <?php } ?>
                            <?php endwhile; ?>
                        </ul>
    
                    <?php endif; ?>
                </div>

    and here is the code for the task modification

    <?php
    //Modals Planning
    // loop through rows (sub repeater)
    if (have_posts()) :
        $args = array(
            'post_type' => 'mon_planning',
            'post_title' => true,
            'posts_per_page' => -1,
            //'author' => $user_id
        );
        $tache = new WP_Query($args);
        while ($tache->have_posts()) : $tache->the_post();
            ?>
            <!--Loop modals -->
            <div class="modal fade modal-modele-fp " id="tache-<?php echo get_the_ID(); ?>" role="dialog">
                <div class="modal-dialog  modal-lg  modal-dialog-centered">
                    <!-- Modal content-->
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                            <h4 class="modal-title" style="width: 100%;text-align: center;">
                                <strong style="    font-size: 26px; "><?php the_title(); ?> </strong>
                            </h4>
                        </div>
                        <div class="modal-body">
                             <span class="badge badge-pill badge-warning"
                                   style="background: #efefef; color: #8c8c8c; ;padding: 5px 10px; font-weight: 500;"><i
                                     class="las la-tag"></i> <?php the_field('categorie_de_tache')  ?></span>
    
                            <i class="lar la-calendar-check"></i> <?php the_field('timming_tache'); ?>
                            <br>
                            <?php $options = array(
                                'form' => true,
                                'post_title' => true,
    
                            );
                            acf_form($options);
                            
                            ?>
                        </div>
                    </div>
                </div>
            </div>
            <!--Loop modals -->
    
        <?php endwhile; // while( has_sub_field('repeater') ):
        ?>
    <?php endif; // if( get_field('repeater') ): ?>

    Now the difficulty is to create default tasks to assign them to all users who have “couples” roles and allow them to modify the task without modifying it for other users who have the same role.
    Currently any changes to the task apply to all other users at the same time.

    How to create editing sessions for this task so that it can be modified for the current user and does not affect other users.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.