lundi 5 octobre 2015

using href when creating wordpress plugin calls empty page instead of php file

I'm currently developing my first wordpress plugin. It's a plugin which manages all the members and other data from a club. I read the members from a MySql database which works fine. What I now want is to set a link to each member name, which will call the details of the member when the user clicked.

I have three php files for now:

1st: menu.php: This just creates a menu item in the backend

2nd: admin.php: This contains the MySql connection and the loop to get all the members. This also contains the link for each member.

3rd: member.php: This file should be the details page to each member (depending on what member the user selected).

while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
    $path = "member.php?memberid=" . $row[0];
    $url = admin_url($path);
    echo "<tr><td>" . $row[0] . "</td><td><a href='{$url}'>" . $row[1] . "</a></td></tr>";
}

As you can see I'm trying to call member.php from admin.php and pass the member's ID using the URL.

My problem now is that when I click on a link, it just call an empty (white) page, without any wordpress design. For testing, I just echoed some random text, but this is not displayed, neither.

What am I doing wrong? Is this even possible in this way? Or how can I achieve this?

I don't know if it helps you helping me, but here you can see the code from menu.php:

add_action('admin_menu', 'AddMenuItem');

function AddMenuItem()
{
    add_menu_page('Admin Plugin', 'Admin Plugin', 'add_users', 'admin-plugin\admin.php', '',  '', 100);
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire