Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save nextab/717fb4c74c08ec0ed6eb356a47d4bcb9 to your computer and use it in GitHub Desktop.

Select an option

Save nextab/717fb4c74c08ec0ed6eb356a47d4bcb9 to your computer and use it in GitHub Desktop.
/* Wenn Submissions über ein JetForm per Gast-Modus zugelassen werden, muss man dem Benutzer später noch die Form Submission zuweisen, damit er diese auch bearbeiten kann; um bei späterer Registrierung die Zuweisung zuzunehmen empfiehlt sich eine entsprechende Logik. Der Shortcode [sort_event_registrations] muss hier noch auf der zugehörigen My …
/* Wenn Submissions über ein JetForm per Gast-Modus zugelassen werden, muss man dem Benutzer später noch die Form Submission zuweisen, damit er diese auch bearbeiten kann; um bei späterer Registrierung die Zuweisung zuzunehmen empfiehlt sich eine entsprechende Logik.
Der Shortcode [sort_event_registrations] muss hier noch auf der zugehörigen My Account Page eingebunden werden. */
#region Assign signups to newly registered users
// Add the action to hook into the user_register event
function nxt_update_event_signups($user_id) {
// Get the newly created user's email
$new_user_email = get_user_data();
if($new_user_email === false) return;
global $wpdb;
// Update the custom table 'wp_jet_cct_anmeldungen'
$table_name = $wpdb->prefix . 'jet_cct_anmeldungen';
// Prepare SQL statement to update entries with the new user ID
$sql = $wpdb->prepare(
"UPDATE $table_name SET cct_author_id = %d WHERE e_mail = %s",
$user_id,
$new_user_email
);
// Execute the query
$wpdb->query($sql);
return;
}
// Shortcode to call the above logic whenever the "my account" page has been accessed
function nxt_fsl() {
nxt_update_event_signups(get_current_user_id());
return;
}
add_shortcode('sort_event_registrations', 'nxt_fsl');
#endregion Assign signups to newly registered users
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment