tags:

views:

23

answers:

1

I've searched around for a while and can't find a solution. From what I've found, I triedadding this into the save_post hook I have:

if ($_POST['post_type'] == 'mmgshowcase')
{
    // ...

    // No thumbnail provided?
    if ($_POST['mmgshowcase_thumbtype'] != 'none' && !has_post_thumbnail($post_id))
    {
        add_filter('redirect_post_location', 'mmgshowcase_error_nothumb_redirect');
        return $post_id;
    }

    // ...
}

And the following code after that function:

function mmgshowcase_error_nothumb_redirect($url)
{
    $url = add_query_arg('error', 'nothumb', $url);
    $url = remove_query_arg('message');
}
if ($_GET['error'] == 'nothumb')
{
    add_action('admin_notices', 'mmgshowcase_error_nothumb');
}
function mmgshowcase_error_nothumb()
{
    echo '<div class="error"><p>herpaderp</p></div>';
}

This code doesn't work, but even if it did, I'd be quite unhappy with it as it seems quite messy and hacky.

Does anyone know of any proper way of doing this, as I just can't find relevant resources?

A: 

You need to pass $url onto remove_query_arg(), and then return it;

$url = add_query_arg('error', 'nothumb', $url);
$url = remove_query_arg('message', $url);
return $url;
TheDeadMedic