Disabling post images for not logged in users

You can use PHP strip_tags and hook to the_content filter by checking if user is logged in. add this to your functions.php file add_filter( ‘the_content’, ‘wpse_remove_img’ ); function wpse_remove_img( $content ){ if( ! is_user_logged_in() ){ // You need to specify which tag you want to keep here it’s p, a, h2,span, div. // Adjust accordingly … Read more

Fatal error: Uncaught Error: Call to undefined function get_userdata()

Generally, forms should be handled on init action or later (mainly in a plugin file, maybe in the theme’s functions.php file, never in a tempalte file), so you can have access to WP functions. add_action( ‘init’, ‘search_form_submit’ ); function search_form_submit(){ $task_name = isset($_GET[‘taskname’]) ? $_GET[‘taskname’] : ”; $meta_key = ‘wp_tasks’; $args = array( ‘post_type’ => … Read more

Custom data-id wp_enqueue_script

script_loader_tag filter was introduced in WordPress 4.1: <?php add_filter( ‘script_loader_tag’, ‘my_script_attributes’, 10, 3 ); function my_script_attributes( $tag, $handle, $src ) { // change to the registered script handle, e. g. ‘jquery’ if ( ‘MY_SCRIPT_HANDLE’ === $handle ) { // add attributes of your choice $tag = ‘<script id=”customID” data-name=”customDataName” src=”‘ . esc_url( $src ) . … Read more