I use admin pointers to show a "tour" of the dashboard. And when the user has taken the tour and pressed the Close button, it saves a value in 'dismissed_wp_pointers' under the specific user in 'wp_usermeta'. This means the user won't see the same "tour" over and over. Which is great! But I would like to create a button which allows me to clear this value. I don't want to delete 'dismissed_wp_pointers' or clear all it's values, I want to remove only the value called 'g_tour' when the button is pressed.
How would I acheive this?
EDIT: I tried this:
<a href="index.php?action=callfunction">Click</a>
<?php
if(isset($_GET['action']) && $_GET['action'] == 'callfunction') {
// Get the dismissed pointers as saved in the database.
$pointers = get_user_meta( $user_id, 'dismissed_wp_pointers', true );
// Create an array by separating the list by comma.
$pointers = explode( ',', $pointers );
// Get the index in the array of the value we want to remove.
$index = array_search( 'tour', $pointers );
// Remove it.
unset( $pointers[$index] );
// Make the list a comma separated string again.
$pointers = implode( ',', $pointers );
// Save the updated value.
update_user_meta( $user_id, 'dismissed_wp_pointers', $points );
}
?>