0

I've added edit|delete options in every row of a table, created in the admin panel.

function column_A( $item ) {
    $actions = array(
        'edit'   => sprintf( '<a href="?page=%s&action=%s&row=%s">%s</a>', 
            $_REQUEST['page'], 'edit', $item['row_id'], 'Edit' ),
        'delete' => sprintf( '<a href="?page=%s&action=%s&row=%s">%s</a>', 
            $_REQUEST['page'], 'delete', $item['row_id'], 'delete' ),

When I click on edit link, I read on browser:

http://.../wordpress/wp-admin/admin?page=myTablePage&action=edit&row=1

Now I would like to call the relative form, using values: action and row.

The forms are placed in the same script, in the function that shows the table page. I've something like this:

function myTablePage() {
    ...
    if ( $action == 'edit' ) {
        ?> <div class="wrap">
        <h2>Form edit</h2>
        <form>...</form>
        </div> <?php
    } elseif ( $action == 'delete' ) { 
        ?> <div class="wrap">
        <h2>Form delete</h2>
        <form>...</form>
        </div> <?php
    } else { 
        ("SHOW THE TABLE) 
    }
    ...
} // end myTablePage

I tried this code, but I don't understand why it doesn't work.

The functions are independent if they are in one script, so I think it's something like the inability to pass the value, but there could be a lot of reasons that I don't know (for example, if this method of passing link could be unsecure).

What's a good method to pass the action=edit/delete link, to a switch case for the form redirecting?

1 Answer 1

0

Sorry for this question, I founded the solution, now I know that i'm a dummy.

if($_GET['action'] == 'edit')

for everyone has my same drama.

(the question remains open for better suggestions about doing that, in the best and most secure way)

Tank you for any suggestion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.