Index

  1. Home
  2. Docs
  3. Index
  4. Code Manager
  5. Write code

Write code

The Code Manager integrates very well with WP Data Access and lets WP Data Access users write their own code and use it in their own projects and publications.

  • Write your own CSS
  • Add interactivity with JavaScript
  • Use PHP to add server logic

Resources

Share reusable code

Want to share your code? Please get in touch!

Was this article helpful to you? Yes No

2 Replies to “Write code”

  1. Hello,
    I want to keep records of the files downloaded from my site. For this, I want to create a new table with wp data access. There will be (user_id, media_id, datetime, user ip) fields in this table.
    When the user wants to download a file, I will first check this table and if user has downloaded it, I will not allow again. Otherwise I want to add a row to this table after the download.

    function isdownloaded (user_id, media_id)
    function addnew (user_id, media_id, user_id)

    How can I write these functions in wp code manager?

    1. Hi Ali,

      Good question! 🙂

      You can write a PHP shortcode and access your table from your shortcode. If your table is stored in your WordPress database, you can use $wpdp to access the database. If your table is stored in another (remote) database, you can use WP Data Access class WPDADB like this:
      $wpdadb = \WPDataAccess\Connection\WPDADB::get_db_connection( $database);

      Where $database is the database where your table is stored. You can use $wpdadb just like you would use $wpdb. Class WPDADB is a sub class of WordPress class wpdb.

      Hope this helps,
      Peter

Leave a Reply

Your email address will not be published. Required fields are marked *

2 + sixteen =