What is the Correct way to pass parameters in function

The following is problematic in the OP’s code snippet: Missing shortcode_atts() for default attribute handling. Incorrectly defining the shortcode’s input argument, use instead function create_my_shortcode( $attr = [], $content = null ){ … } Not escaping user input, check e.g. wpdb::prepare(). We want to avoid possible SQL injections. Uses hardcoded table prefix, wp_, instead of … Read more

Modify Database in Multi-Site wp_usermeta table

This Should Work? ALTER TABLE wp_usermeta ADD COLUMN old_user_id bigint(20) unsigned; INSERT INTO wp_usermeta (old_user_id) SELECT u.id FROM wp_users AS u; INSERT INTO wp_usermeta (user_id, meta_key, meta_value) SELECT u.id, ‘wp_2_capabilities’, meta_value JOIN wp_users AS u ON u.user_id = u.old_user_id; ALTER TABLE wp_users DROP COLUMN old_user_id;

database interactions using OOP

This is potentially a fairly involved question, so I may not be totally rigorous in my answer, but this should give you a good start when creating and deleting tables.. Include the following lines in your plugin _construct() function of class_my_plugin.php: if (is_admin()){ //manage the the database tables when registering or deactivating register_activation_hook($loc, array($this, ‘your_plugin_installation’)); … Read more

Foreach loop using $wpdb not results from rows

First of all, you should never concatenate SQL Query with any variables this way – it will cause SQL Injection vulnerability. Also… get_results method returns just an array of results. You can’t use it as an object and get num_rows from it – there is no such property in an array (it’s a property of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)