Error while setting role

You have to use just $current_role variable instead of $current_role[0], because call get_user_meta( $author->ID, ‘wp_capabilities’ ); will return you array with roles as keys. <?php add_action( ‘save_post’, ‘update_roles’ ); function update_roles( $post_id ) { if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return $post_id; // Get the author $author = wp_get_current_user(); // Set variables for … Read more

Weird string offset errors when displaying post attachments

Since you’ve used the true argument for get_post_meta, $blogimages will be a single array, not a multidimensional one. So instead of $blogimages[0][‘blog-image-inside’], just use $blogimages[‘blog-image-inside’]. For absolute sanity, you might also want to check $blogimages before you use it: ‘exclude’ => [ $thumb_ID, isset( $blogimages[‘blog-image-inside’] ) ? $blogimages[‘blog-image-inside’] : 0, isset( $blogimages[‘blog-image-front’] ) ? $blogimages[‘blog-image-front’] … Read more

Fix Warnings that shouldn’t be necessary to fix

So there’s two things going on here. Firstly get_the_category() doesn’t accept a category ID as a parameter. It accepts a post ID for which to get categories from. Judging by your code you need to use get_category(): $category = get_category( get_query_var(‘cat’) ); The other problem is that you seem to be using $cat_name without checking … Read more

Warning on my WordPress site [closed]

There is not a single reason why you see this type of warning. A nulled theme or plugin is a happy ground for malware, virus rootkits, backdoors and more. As this is true for most sites Major Browser and Search Engines are taking steps to protect the users. As such warnings exist for the protection … Read more

How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286

Replace ‘call_user_func_array’ with name of the function to be called to output the page content. add_action(‘admin_menu’, ‘personalised_menu’); function personalised_menu() { add_menu_page( ‘Page Title’, ‘Blog’, ‘edit_posts’, ‘menu_slug’, ‘display_main_page’, ‘dashicons-welcome-write-blog’ ); add_submenu_page( ‘menu_slug’, ‘Add New Page’, ‘Add New’, ‘edit_posts’,’add_new_page’, ‘display_secondary_page’ ); } function display_main_page() { echo ‘Content of “Page Title”‘; } function display_secondary_page() { echo ‘Content of … Read more

Warning message (re. php) on the blog page

<a href=”https://wordpress.stackexchange.com/questions/364537/<?php//echo esc_url( home_url(“https://wordpress.stackexchange.com/” ) ); ?>”><?php// bloginfo( ‘description’ ); ?></a> The <?php// is the problem. PHP blocks are started with <?php but the code uses <?php//. Instead, change it to <?php //, or better yet, since // is meant to comment an entire line out, use /* */ style commenting instead

Illegal string offset in PHP function

You need to be validating a couple of parts about $filearray before you use it. There are some good suggestions in the comments, I think a couple of robust examples would serve you well too: Using empty() function wp_custom_attachment() { wp_nonce_field( plugin_basename(__FILE__), ‘wp_custom_attachment_nonce’ ); $html=”<p class=”description”>Upload your PDF here.</p>”; $html .= ‘<input id=”wp_custom_attachment” name=”wp_custom_attachment” size=”25″ … Read more

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