dou4624 2015-09-27 03:56
浏览 58

add_action和函数不起作用

I have added the following code to try and add a table to an existing function within a WordPress plugin.

The code I am trying to add below just results in a blank page on my site (i.e Does not load).

The code is as below

function my_attendee_form ()
{
    $people = array();
    $EM_Bookings = $EM_Event->get_bookings();
    if (count($EM_Bookings->bookings) > 0) 
    {
        echo "
";
        ?>
        <table class="event-attendees">
            <tr class="">
                <th class="attendee-name">Name</th>
                <th class="attendee-country">Golf Link</th>
                <th class="attendee-discipline">Handicap</th>
                <th class="attendee-status">Home Club</th>
            </tr>
            <?php
            $guest_bookings = get_option('dbem_bookings_registration_disable');
            $guest_booking_user = get_option('dbem_bookings_registration_user');
            $counter = 0;
            foreach ($EM_Bookings as $EM_Booking) {
                $attendees_list = "";
                $attendees = $EM_Booking->booking_meta['attendees'];
                if (!empty($attendees)) {
                    $attendees_list = "";
                    foreach ($attendees as $key => $value) {
                        foreach ($value as $key_attendee => $value_attendee) {
                            $attendees_list .= "<tr>";
                            $attendees_list .= "<td>".$value_attendee["attendee_name"]."</td>";
                            $attendees_list .= "<td>".$value_attendee["golflink"]."</td>";
                            $attendees_list .= "<td>".$value_attendee["handicap"]."</td>";
                            $attendees_list .= "    <td>".$value_attendee["home_club"]."</td>";
                            $attendees_list .= "</tr>";
                        }
                    }   
                }
                echo $attendees_list;
            }
            echo "
";
            ?>
        </table>
        <?php
        if (count($EM_Bookings->bookings) == 0) 
        {
            echo '<p>No one registered yet... Will you be the first ?</p>'
        };

Is there any suggestions why this may fail?

The code itself works if I add it to a page as a HTML div, but when I add it to as a function no luck.

Any thoughts would be great?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)