Front end login form not working on live site

Do not use wp_login function it is deprecated , instead use wp_signon. wp_signon function returns WP_Error on failure so use it to evaluate condition as following. <?php if ( ‘POST’ == $_SERVER[‘REQUEST_METHOD’] && !empty( $_POST[‘action’] ) && $_POST[‘action’] == ‘log-in’ ) : $login = wp_signon( array( ‘user_login’ => $_POST[‘user-name’], ‘user_password’ => $_POST[‘password’], ‘remember’ => $_POST[‘remember-me’] … Read more

upload file with front-end submission and forward the data in an email

In case anyone needs this, here is my solution: if ($_FILES) { function insert_attachment($file_handler, $post_id, $setthumb = ‘false’) { if ($_FILES[$file_handler][‘error’] !== UPLOAD_ERR_OK) __return_false(); require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’); $attach_id = media_handle_upload( $file_handler, $post_id ); //get url $attachment_url = wp_get_attachment_url($attach_id); add_post_meta($post_id, ‘_file_paths’, $attachment_url); $attachment_data = … Read more

Delete post meta front end

For anyone else looking for guidance on how to do this, I created another custom field called event_status and by using the save_post action in wordpress set a condition that once this changes to then the run delete_post_meta action as follows: function event_status_is_updated($post_id){ if(get_post_meta($post_id,’event_status’,true)==’not_complete’){ delete_post_meta($post_id,’date_dun’); } } add_action(‘save_post_event’,’event_status_is_updated’);

How to change custom post order ASC/DESC menu_order wise dynamically?

You can hook pre_get_posts and use the order_by argument of WP_Query. From a plugin or functions.php of active theme, something like the following (untested example): add_action( ‘pre_get_posts’, ‘my_post_type_sort’, 10, 1); function my_post_type_sort( $query ) { if ( is_admin || ! $query->is_main_query() ) { return; } if ( $query->get(‘post_type’) !== ‘name_of_post_type’ ) { return; } $query->set(‘orderby’, … Read more

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