Articles of front end

WordPress Frontend Check If Current User Is Administrator

I am trying to check if current user that accessing a page if administrator using current_user_can(), but it is not working and returning this message instead: Fatal error: Call to undefined function wp_get_current_user() in /home/******/public_html/wordpress/wp-includes/capabilities.php on line 1329 What can I use to check whether a user is admin or not in the front end? […]

WordPress Frontend Post Form (Bootstrap Modal) Not Creating Post

I have a form in a separate PHP file in the theme directory and it’s being included in the sidebar of the main page template. The form is inside a Boostrap modal. I’ve been trying to use this code to be able to allow the users to submit new posts using the form but this […]

Update ACF fields on a frontend form?

I have the form below to update posts in a custom post type. In my custom post type I have some ACF fields which I also need to be able to update, but unsure how. I can update my default WordPress fields and can call in the ACF field data into the field I want […]

Reason action hook won't work with update_post_meta from frontend form? Alternative?

The code below works when I am inserting a post/using add_post_meta when submitting a form. The page refresh is flawless (see How can I fix a slow redirect after form submit from frontend (no plugin)?). However, I can’t seem to get the same effect when using forms that I intend to update the post meta […]

Showing user profile data on front-end

I’m making a profile-page so my members can update they’re details trough the front-end. The problem is that the select-box named “Province” won’t show the correct data when the page loads. How can i make the select-box load the correct data when the user enters the page? Here is the code i have in functions.php […]

How to request admin-ajax.php correctly when wordpress URL and site URL are different?

When site_url() and home_url() are different, how a request should be directed to admin-ajax.php (both in front-end and admin)? Using A. admin_url(‘wp-admin/admin-ajax.php’) or B. home_url(‘wp-admin/admin-ajax.php’) Usually method A is used. However for some websites this request gives error 404 in front-end. Method B does not work when wordpress is located in some sub-directory with respect […]

Static page not working

First, context: I am not developing a theme, I am not mucking around with PHP. All I wanted to do was throw up a quick temporary WordPress site in a few minutes, paste my content in, and call it “good enough” for a month until I could sit down and dedicate real time to building […]

Display custom meta on page that has been check in custom post type

I have created a custom post type (cpt) and within each post type is a custom meta field. This custom meta field displays all the pages that can ‘checked’. Code to generate the custom meta box: // display list of pages with check box function page_meta_box( $post ) { // Nonce to verify intention later […]

How to display the user's comment status on the front end

How can I display the current status of a user’s comment/s (on the front end), that is, “approved” or “pending”

Upload and attach to a post multiple image files

In a front end form I have a ‘multiple’ input field for uploading and attaching images to a post and a processing script (from here). I expect that will be uploaded and attached all files that I have selected, but this doesn’t happens. Is uploaded and attached only the last selected file (in alphabetical order). […]