Skip Navigation

[Resolved] Custom Posts Titles

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Author
Posts
#1908413

Tell us what you are trying to do?
I am creating a member only directory. viewable only by other members.
I am using the tutorials for both membership and directory.
The most important part of the directory will be to search by location.
I am using a user-form for sign-up that just has email address, username, nickname and password. All other information is in a post- form called Profile. The post form "Profile" will be what is used in all views and searches. I am using a custom post type called Members.

I have a couple of questions:
should I include first and last name on the user form? If I do, then should I include it again on the post-form.
Since the post-form creates new Member posts, I am trying to figure out what to do with the Post Title. It is not (as in your example) a recipe name, that I would enter. And I can't quite figure out how to have the First and Last Name (or company name) be the title of the post. or does it need to be?

Thanks so much

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

#1908449

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Screen Shot 2021-01-17 at 2.56.35 PM.png

Hi, I understand your concern, but it's difficult for me to say one way or the other how your data should be structured without understanding the requirements of what you want to accomplish. There's nothing in WordPress or Toolset that absolutely requires a User to have a first or last name, or that the values are stored separately in custom fields, or that a Member post that acts as a proxy for Users includes the first and/or last name in the post title. It all depends on what you want to do with this data later. If there is ever a case where you need the first and last names stored separately, for example, a sortable table of Members with separate columns for first and last names, then you must store those values separately in individual fields.

should I include first and last name on the user form?
It's really up to you, because the First Name and Last Name criteria are not required by WordPress to create or edit a User account. There may be situations where 3rd-party systems use the First and Last name fields from a User account for some reason, but since they are not required by WordPress those 3rd-party systems probably have fallbacks in place like the username or nickname fields instead. Will you need this data in the User profile in the future? I cannot predict this. If you have it in the Member account, then you will be able to access that information if necessary. I would keep in mind that if you do decide to use these fields later, getting that data later is more difficult than requiring it up front when Users are created.

If I do, then should I include it again on the post-form
It's up to you...do you want the User to be able to potentially modify the first and last name values between the time they create the User account and the time they generate their Member post? They would be different from the User account values, which could lead to some confusion when examining data in the backend of the site. You can include the input fields in the post Form and pre-fill the input fields with data from the User profile automatically using shortcodes. That would be convenient, and would help speed up the Form submission process. You could optionally set those input fields to be read-only, preventing modification. So it just depends on your preference and the requirements for the data later. Regardless of whether or not you include the inputs in the Member Form, and regardless of whether or not the inputs are editable, I think it is definitely important to store first and last name fields in the Member post. This will allow your site Users to search for users by first and/or last name when performing text searches in Views.

It also might be important for your Users to be able to sort and filter a list of Members. If you don't store first and last name separately, it will not be possible to create a list of Members in a sortable table with separate columns for first and last name. So storing the values separately is definitely important in that case.

And I can't quite figure out how to have the First and Last Name (or company name) be the title of the post. or does it need to be?
Again, up to you whether or not it needs to be. I think it's a good idea if for no other reason than making post management easier in the backend of wp-admin. The post title is displayed in the list of Member posts at wp-admin > Members > All Members, and whenever working with posts in wp-admin, so it would be intuitive to use the first and last name values here, or the unique username, or some combination depending on what you want to do with the data later. Generally speaking, post titles are an important part of SEO and search, so you should consider the impact of post title carefully when evaluating the components of a good post title.

Let's assume you do decide to include First Name and Last Name in the User Form, and you make both fields required. Then, you want to set the Member post title automatically to be the User's First Name, plus a space, plus the User's Last Name. In the Member Form, you can automate the value of the post title field using the User name fields with Views shortcodes. In expert mode, you would edit the post title shortcode like this:

[cred_field field='post_title' class='form-control' output='bootstrap' value='[wpv-user field="user_firstname"] [wpv-user field="user_lastname"]']

In the drag-and-drop Form builder (not expert mode), you would include the two Views shortcodes in the default value of the Post Title field block:

[wpv-user field="user_firstname"] [wpv-user field="user_lastname"]

Screenshot attached here.

#1908463

thank you for an amazing answer! yes.! I want the first (space) last name to be the default post title.
I apologize, I am brand new to this plug in - and on a super heavy learning curve to find where things go and where they live.

One clarification. I will be getting the first and last name from the post form. That is where I am having the problem. I am guessing that the correct way to call it would be: [cred_field field='first_name ]? Also, how can I hide the title from showing up as an input on the form?

#1908467

Actually, I reread what you wrote and it makes perfect sense to do what you said. They register as a user with their fist and last name and then when they fill out the member post form, I can populate with that information (CAN you please tell me how?).

But, then I am still stuck on how to get the title to be their first and last name from the user account - without displaying the Title field on the member form.

Thanks so much
W

#1908469

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

One clarification. I will be getting the first and last name from the post form. That is where I am having the problem. I am guessing that the correct way to call it would be: [cred_field field='first_name ]?
Are you asking how to include an input field in the Form itself? Assuming you create a custom field in Types, the Form builder will generate the appropriate shortcodes for you automatically so there's no need to worry about the syntax for creating the individual inputs. After the Form is submitted, if you want to display that first name value, you can use Types field shortcodes in your site's templates. Types field shortcodes look like this:

[types field="field-slug"][/types]

Those shortcodes are generated automatically when you use the Fields and Views button above a text editor area to insert a Types field, so no need to worry about the syntax. It's automatically generated. If you want to customize the field, we have information about various Types field shortcode attributes available here: https://toolset.com/documentation/customizing-sites-using-php/functions/

Or if you're using the Blocks editor to design your templates, you would insert a Single Field block in the design and select the first name custom field to be displayed by the Single Field block. Again, no need for worrying about syntax.

Also, how can I hide the title from showing up as an input on the form?
In the expert Form builder where you have more control over the HTML markup, you can use a wrapping div with CSS to hide an input:

<div style="display:none;">
[cred_field field='post_title' class='form-control' output='bootstrap' value='[wpv-user field="user_firstname"] [wpv-user field="user_lastname"]']
</div>

In the non-expert Form builder, you would include two custom HTML blocks - one above the post title field and another below the post title field. In the first HTML block you would include:

<div style="display:none;">

In the second HTML block you would close that wrapping div:

</div>
#1908643

My issue is resolved now. Thank you!