高级自定义字段在密码后显示

时间:2015-07-09 作者:itsWrongGuy

我是ACF的新手,到目前为止,我设法添加了一个新的自定义字段,并做到了这一点

enter image description here

enter image description here

访问者可以输入应用程序编号和密码,以获取管理员添加的应用程序状态。

我使用了Repeater,对我来说工作起来感觉更好,只剩下一个问题,get\\u field()的参数是(field name,post id),在我的例子中,我在上面提到的工作中称它为application\\u id。用户如何通过我将以整数格式分配的应用程序编号进行搜索。到目前为止,我已经做到了这一点(忽略内联css)

enter image description here

            <div class="entry-content">
            <form method="post">
              <label>Enter Application ID:</label>
              <input type="text" name="application_id">
              <label>Enter Password:</label>
              <input type="password" name="application_pass">
              <center style="margin: 10px 0;"><input type="submit" name="submit" value="search"></center>
            </form>
            <?php 
                $application_id = $_POST["application_id"];
                $entered_pass = $_POST["application_pass"];
                $client_name = get_field("client_name", $application_id);
                $program = get_field("program", $application_id);
                $password = get_field("password", $application_id);
                $application_status = get_field("application_status", $application_id);

                if ($entered_pass == $password) {
                    echo "  <div><span style=\'width:40%; float:left; font-weight: bold;\'>Client Name:</span> <span style=\'width:60%; float:left;\'>{$client_name} </span></div>
                            <div><span style=\'width:40%; float:left; font-weight: bold;\'>Program Applied: </span> <span style=\'width:60%; float:left;\'> {$program} </span></div>
                            <div><span style=\'font-weight: bold;\'>Application Status:</span> <hr style=\'margin:3px;\'>" ?>
                    <?php $x = 1;
                    if(get_field(\'application_status\', $application_id)): ?>
                            <ul style="list-style: outside none none; font-weight: bold;">
                                <li style="width: 5%; float: left;">S#</li>
                                <li style="width: 78%; float: left;">Description</li>
                                <li style="width: 17%; float: left;">Date</li>
                            </ul>
                            <hr style=\'margin:3px;\'>
                        <?php while(the_repeater_field(\'application_status\', $application_id)): ?>
                            <ul style="list-style: outside none none;">
                                <li style="width: 5%; float: left;"><?php echo $x; $x++; ?></li>
                                <li style="width: 78%; float: left;"><?php the_sub_field(\'last_update\'); ?></li>
                                <li style="width: 17%; float: left;"><?php the_sub_field(\'update_date\'); ?></li>
                            </ul>
                        <?php endwhile; ?>
                    <?php 
                    endif;
                    ?>

                <?php "</div>";} ?><!-- entered pass if -->

        </div><!-- .entry-content -->

1 个回复
最合适的回答,由SO网友:itsWrongGuy 整理而成

好了,我终于读了很多文章,最后我把一切都搞定了。因此,如果其他人陷入同样的情况,现在有一个解决方案。

        <article id="" class="page type-page status-publish hentry">

        <header class="entry-header">
            <h1 class="entry-title">Check Application Status</h1>   
        </header><!-- .entry-header -->

        <div class="entry-content">
            <form method="post">
              <label>Enter Application ID:</label>
              <input type="text" name="application_id">
              <label>Enter Password:</label>
              <input type="password" name="application_pass">
              <center style="margin: 10px 0;"><input type="submit" name="submit" value="search"></center>
            </form>
            <?php 
                $application_id = $_POST["application_id"];
                $entered_pass = $_POST["application_pass"];
            ?>
            <?php 
            $posts = get_posts(array(
                \'posts_per_page\'    => 1,
                \'post_type\'         => \'applications\',
                \'meta_query\'    => array(
                                        \'relation\'      => \'AND\',
                                            array(
                                                \'key\'       => \'application_no\',
                                                \'value\'     => $application_id
                                            ),
                                            array(
                                                \'key\'       => \'password\',
                                                \'value\'     => $entered_pass
                                            )
                                    )
            ));
            ?>
            <?php foreach( $posts as $post ): 
                setup_postdata( $post )
                ?>
                <?php   $x = 1;
                        echo "Name: "; the_field("client_name"); echo "<br />";
                        echo "Application Number: "; the_field("application_no"); echo "<br />";
                        echo "Program: "; the_field("program"); echo "<br />";
                        echo "Application Status: "; 
                        ?>
                        <ul style="list-style: outside none none; font-weight: bold;">
                                            <li style="width: 5%; float: left;">S#</li>
                                            <li style="width: 78%; float: left;">Description</li>
                                            <li style="width: 17%; float: left;">Date</li>
                                        </ul>
                                        <hr style=\'margin:3px;\'>
                        <?php 
                        while(the_repeater_field(\'application_status\')): ?>
                            <ul style="list-style: outside none none;">
                                <li style="width: 5%; float: left;"><?php echo $x; $x++; ?></li>
                                <li style="width: 78%; float: left;"><?php the_sub_field(\'last_update\'); ?></li>
                                <li style="width: 17%; float: left;"><?php the_sub_field(\'update_date\'); ?></li>
                            </ul>
                        <?php endwhile;
                ?>
            <?php endforeach; ?>
            <?php wp_reset_postdata(); ?>
        </div><!-- .entry-content -->
    </article>

结束

相关推荐

高级自定义字段在密码后显示 - 小码农CODE - 行之有效找到问题解决它

高级自定义字段在密码后显示

时间:2015-07-09 作者:itsWrongGuy

我是ACF的新手,到目前为止,我设法添加了一个新的自定义字段,并做到了这一点

enter image description here

enter image description here

访问者可以输入应用程序编号和密码,以获取管理员添加的应用程序状态。

我使用了Repeater,对我来说工作起来感觉更好,只剩下一个问题,get\\u field()的参数是(field name,post id),在我的例子中,我在上面提到的工作中称它为application\\u id。用户如何通过我将以整数格式分配的应用程序编号进行搜索。到目前为止,我已经做到了这一点(忽略内联css)

enter image description here

            <div class="entry-content">
            <form method="post">
              <label>Enter Application ID:</label>
              <input type="text" name="application_id">
              <label>Enter Password:</label>
              <input type="password" name="application_pass">
              <center style="margin: 10px 0;"><input type="submit" name="submit" value="search"></center>
            </form>
            <?php 
                $application_id = $_POST["application_id"];
                $entered_pass = $_POST["application_pass"];
                $client_name = get_field("client_name", $application_id);
                $program = get_field("program", $application_id);
                $password = get_field("password", $application_id);
                $application_status = get_field("application_status", $application_id);

                if ($entered_pass == $password) {
                    echo "  <div><span style=\'width:40%; float:left; font-weight: bold;\'>Client Name:</span> <span style=\'width:60%; float:left;\'>{$client_name} </span></div>
                            <div><span style=\'width:40%; float:left; font-weight: bold;\'>Program Applied: </span> <span style=\'width:60%; float:left;\'> {$program} </span></div>
                            <div><span style=\'font-weight: bold;\'>Application Status:</span> <hr style=\'margin:3px;\'>" ?>
                    <?php $x = 1;
                    if(get_field(\'application_status\', $application_id)): ?>
                            <ul style="list-style: outside none none; font-weight: bold;">
                                <li style="width: 5%; float: left;">S#</li>
                                <li style="width: 78%; float: left;">Description</li>
                                <li style="width: 17%; float: left;">Date</li>
                            </ul>
                            <hr style=\'margin:3px;\'>
                        <?php while(the_repeater_field(\'application_status\', $application_id)): ?>
                            <ul style="list-style: outside none none;">
                                <li style="width: 5%; float: left;"><?php echo $x; $x++; ?></li>
                                <li style="width: 78%; float: left;"><?php the_sub_field(\'last_update\'); ?></li>
                                <li style="width: 17%; float: left;"><?php the_sub_field(\'update_date\'); ?></li>
                            </ul>
                        <?php endwhile; ?>
                    <?php 
                    endif;
                    ?>

                <?php "</div>";} ?><!-- entered pass if -->

        </div><!-- .entry-content -->

1 个回复
最合适的回答,由SO网友:itsWrongGuy 整理而成

好了,我终于读了很多文章,最后我把一切都搞定了。因此,如果其他人陷入同样的情况,现在有一个解决方案。

        <article id="" class="page type-page status-publish hentry">

        <header class="entry-header">
            <h1 class="entry-title">Check Application Status</h1>   
        </header><!-- .entry-header -->

        <div class="entry-content">
            <form method="post">
              <label>Enter Application ID:</label>
              <input type="text" name="application_id">
              <label>Enter Password:</label>
              <input type="password" name="application_pass">
              <center style="margin: 10px 0;"><input type="submit" name="submit" value="search"></center>
            </form>
            <?php 
                $application_id = $_POST["application_id"];
                $entered_pass = $_POST["application_pass"];
            ?>
            <?php 
            $posts = get_posts(array(
                \'posts_per_page\'    => 1,
                \'post_type\'         => \'applications\',
                \'meta_query\'    => array(
                                        \'relation\'      => \'AND\',
                                            array(
                                                \'key\'       => \'application_no\',
                                                \'value\'     => $application_id
                                            ),
                                            array(
                                                \'key\'       => \'password\',
                                                \'value\'     => $entered_pass
                                            )
                                    )
            ));
            ?>
            <?php foreach( $posts as $post ): 
                setup_postdata( $post )
                ?>
                <?php   $x = 1;
                        echo "Name: "; the_field("client_name"); echo "<br />";
                        echo "Application Number: "; the_field("application_no"); echo "<br />";
                        echo "Program: "; the_field("program"); echo "<br />";
                        echo "Application Status: "; 
                        ?>
                        <ul style="list-style: outside none none; font-weight: bold;">
                                            <li style="width: 5%; float: left;">S#</li>
                                            <li style="width: 78%; float: left;">Description</li>
                                            <li style="width: 17%; float: left;">Date</li>
                                        </ul>
                                        <hr style=\'margin:3px;\'>
                        <?php 
                        while(the_repeater_field(\'application_status\')): ?>
                            <ul style="list-style: outside none none;">
                                <li style="width: 5%; float: left;"><?php echo $x; $x++; ?></li>
                                <li style="width: 78%; float: left;"><?php the_sub_field(\'last_update\'); ?></li>
                                <li style="width: 17%; float: left;"><?php the_sub_field(\'update_date\'); ?></li>
                            </ul>
                        <?php endwhile;
                ?>
            <?php endforeach; ?>
            <?php wp_reset_postdata(); ?>
        </div><!-- .entry-content -->
    </article>

相关推荐