最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp admin - How do I edit an add in wp_list_table and return to same page

programmeradmin0浏览0评论

I am just not understanding something and apparently, I don't know what it is. I have a wp_list_table that I use to manage a table. I have it working correctly but I would like to edit the values entered. If an error is found, I would like to show an error message at the top of the page that originated the action followed by the original page. Here is the code that I have in my form handler to do this function.

        // New or edit?
        if ( ! $id ) {
            // new
        // make sure add name is valid
            $table_name = $wpdb->prefix . 'golf_pool_team_roster';
            $add_player_name = $fields['add_player_name'];
            $drop_player_name = $fields['drop_player_name'];
            $sql = 'SELECT  * FROM ' . $table_name . ' WHERE player_name = "' . $drop_player_name . ' "';
            $result = $wpdb->get_row($sql);
            if($result == NULL) {
                $message =  $drop_player_name . ' not on anyone's roster.';
                $redirect_to = add_query_arg( array( 'message' => 
                    $message));
                wp_safe_redirect( $redirect_to );
                exit;
            }

This takes me back to the starting page, but not error message. When I wp_die($redirect_to, this is returned. '/wordpress/wp-admin/admin.php?page=drop_add&action=new%27s_roster_&message=Tommy Smith not on anyone's roster.'

I would sure appreciate some help.

发布评论

评论列表(0)

  1. 暂无评论