Implementing update_user_meta


I am busy making a page in which users can choose between a variety of programs and subscribe to one.

Once the users have subscribed to a program, his/her choice has to be saved in the database. Later when the user visits the webpage again, he/she can see the programs they have subscribed to. I am trying to save the programs the user has subscribed to with update_user_meta. Later I want to view them on the download page with the get_user_meta.

My question: I do not know how to implement update_user_meta in my code. How can I do that?

My code:


global $wpdb;
// this adds the prefix which is set by the user upon instillation of wordpress
$table_name = $wpdb->prefix . "wpex_programma";
// this will get the data from your table
$retrieve_data = $wpdb->get_results( "SELECT Anaam FROM wpex_programma;" );
<form action="#" enctype="multipart/form-data" method="post">
<?php foreach ($retrieve_data as $retrieved_data) { ?>
     <th>Programma:</th><td style="vertical-align: middle;"><?php echo $retrieved_data->Anaam;?></td>
     <th><input name="submit" type="submit" value="Abonneer" /></th>
//This is ment to insert the username and choice in the database. However, I want to use update_user_meta
if(isset($_POST["submit"])) {
  global $wpdb;
     $number_of_rows_inserted = $wpdb->insert('wpex_JNCT_users_programma', [
      'users' => "test",
      'programma' => $retrieved_data

Parsa_237 4 years 2020-03-23T12:51:50-05:00 0 Answers 104 views 0

Leave an answer