I have created a Custom Post Type with the Custom Post Type UI plugin.
I have added a number of custom fields which are connected to this custom post type.
I want to create a Backend View for the custom post type where the user can see the post without the ability to Edit the post.
I need help on the following issues:
Overriding the 'View' button shown for every entry to point to the 'Backend View' page
Creating the 'Backend View'
Edited due to a suggestion:
The Custom Post type that I have created isn't shown through the website it is meant as Booking, each Booking input is added as a post entry, which currently can only be viewed in Edit mode. Which creates a problem as I want the edit mode to be available to 'Super' Admins only.
Apart from the above the View button which is automatically shown for each entry directs you to the homepage, I want this to be either overriden and directed to a View page or completely removed so to not confuse the users.
Related
I am using a plugin that creates a shortcode for displaying user profile data in the frontend. I needed to add extra data which I made possible thanks to ACF plugin. I have been able to follow how-tos and the ACF fields now display in the frontend. This is where I am losing it.
When I view the page that displays the profile e.g example.com/profile/user, my code instead checks fields for the currently logged-in user instead of the user that I am looking at.
I cannot use get_the_author_meta() because I am manually creating the users so using that checks back for the author and instead of returning the original author it returns mine (which is how it's meant to work anyways).
Example of how I am fetching data
get_user_meta( $current_user->user_login, 'specialty', true )
specialty is the name of my custom field which I have added for user.
How can I fetch the intended username of the user I just created?
Thanks.
Is there a way in which I can disable/hide specific fields from the "page form" in the back-end? I have currently test two plugins but none of them meet the requirement that I have, like for example this plugin "User Role Editor by Members – Best User, Role and Capability Management Plugin for WordPress":
I'm sorry that the options are in spanish but the capabilities options are for example: "edit pages", "edit other people's pages", "publish pages", "delete pages"... What I want is to hide certain sections to the "editor" user role from the page form:
Is this even possible?, and if not, what alternatives do I have?, the thing is that I'm afraid that whoever is in charge of editing will end up messing up with the pages...
Use Adminimize plugin It will resolve problem easily.
This plugin changes the administration back-end and gives you the power to assign rights on certain parts.
In most cases, the plugin "Adminimize" that Tech Sourav mentioned will work just fine, but since this page I'm working with is using some annoying custom content editor and other theme tools, the workaround that I ended up doing was:
Create a custom post type with the "Custom Post Type UI" plugin.
In this case I will only and always have 3 pages that have this "modifiable" price field, so once the custom post type is added I added 3 entries to this custom post type (here I will show you just one).
I'm also using the "advanced custom fields pro" plugin in order to create this price field into my entries.
When the custom field has been created there's this option inside the same previous form that allows me to show that specific field just created into specific post types entries, so I made up the rules in order to show this field in the created custom post type entries:
In this example I'm just showing you the rule for one entry, in order to make it appear on the other 2 entries, I would just click in the "agregar grupo de reglas" and select one by one.
Once this custom field and rules are configured correctly, I should see now the custom field "precio" inside my specified entries form:
After saving the entry with the updated custom field value, I will now check the post id and save it for later (we're going to need it):
According to the documentation of Advanced Custom Fields plugin I can show the saved value of certain input within certain post with the shortcode: [acf field="{$field_name}" post_id="{$post_id}"], in this case I will change the values to: [acf field="precio" post_id="1372"] and paste the code into the section of the page that I will show this:
The builder that this page is using has an element called "code block" but you can use it in the equivalent element that allows you to paste code from your theme.
After saving the changes, now the only thing that I have left is to restrict the ability to edit pages to a user with the "editor" role, for this I will use the plugin that I mentioned before in my question called "User Role Editor by Members – Best User, Role and Capability Management Plugin for WordPress":
As you can see, I will not let editor users to mess up with the pages post types, so with this, they will only be able to edit the custom post type that I created, which even if they write something inside the content of that custom post type entry, the website won't be affected at all. This may be a little bit hacky but it works...
Ok, so my client has a database which has 500+ posts, and he wants me to create the second database where custom post type should place and read data from it.
The reason why is because there will be an option for visitors to come and fill the form that will write in database columns and save as draft post for admin to review. After validation from dashboard admin will publish that post and post will list in custom post type archive page. Custom post type also has custom taxonomy.
How would I go about using a different DB for only those custom post types, for reading and updating?
For that, you could use the multisite functionality in Wordpress
that will provide you the facility to create the tables in the same database but with a different prefix.
Hope this will help you out.
I have replaced my entity with Blog to explain better.
I have the following route:
Route::get('/blog-category', 'BlogController#showBlogCategory')
which shows a form with a dropdown of different blog categories and some other input fields related to the category
The form POSTs to the following:
Route::post('/blog-details', 'BlogController#showBlogDetails')
Here I validate the request the form and return back if there is an invalid blog category or if it is missing
This method is called showBlogDetails because the category and the other fields are passed on to the next view return view('blog-details', compact('blogCategoryData'))
In this view there is a form to fill in the rest of the blog details.
Both the blogCategoryData (each data has a hidden input field) and the blog details are POSTed to the following route:
Route::post('/blog-store', 'BlogController#store')
This is also validated using a Request but if it fails it tries to go back, which it can't do as only POST is allowed to get there.
I need the blog category fields before I can show the blog details and a Blog cannot be created without either stuff so I can't temporarily create one either.
This flow of selecting/filling in blog category fields and then entering details is a requirement so has to be done in that order, in 2 different pages.
So currently it is:
GET -> POST (validate) -> POST (validate)
What is the best way around this or how would I make my current flow work?
one way is to use javascript and of course ajax to fetch blog data and show corresponding section. first the page only shows categories drop down box. after changing that to a correct category page makes an ajax request and fetches data. then replaces it in a hidden 'div' and shows it.
another way is to bring replace the categories box in the previous page.
When creating a custom post type in wordpress for dynamic items, such as portfolio items, some fields may be unsable for certain portfolio items. But, if you leave this field out, there will be a validation error in wordpress, because the field is a necessary according to WordPress. How can someone make certain fields in the custom post type optional? So no validation errors occur?
To make the field optional, simply go to admin dashboard, scroll down the left navigation panel and click Custom Fields. Then, click on the post type you'd like to edit. Click on a field you want to make optional, and you will see a check box for yes or no -- click no. Click Update. The field will no longer be required!