function edit_button_shortcode() { // Check if the user is logged in if (is_user_logged_in()) { global $wpdb; $user_id = get_current_user_id(); // Check if the user's ID exists in the wp_fluentform_submissions table $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}fluentform_submissions WHERE user_id = %d", $user_id)); // If the user's ID exists in the table, display the "Edit" button if ($results) { return '<a href="YOUR_EDIT_URL_HERE" class="edit-button">Edit</a>'; } } return ''; // If the user is not logged in or their ID doesn't exist in the table, return an empty string } add_shortcode('edit_button', 'edit_button_shortcode');
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter