最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Implementing update_user_meta

programmeradmin2浏览0评论

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:

<?php

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;" );
//print_r($retrieve_data);
?>
<form action="#" enctype="multipart/form-data" method="post">
<table>
<?php foreach ($retrieve_data as $retrieved_data) { ?>
<tr>
     <th>Programma:</th><td style="vertical-align: middle;"><?php echo $retrieved_data->Anaam;?></td>
     <th><input name="submit" type="submit" value="Abonneer" /></th>
  </tr>
<?php 
}
//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
     ]);
}

?>
</table>
</form>

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论