Skip Navigation

[Resolved] Cred form relationship default value as current user

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 1 voice.

Last updated by Minesh 2 months ago.

Assisted by: Minesh.

Author
Posts
#2800598

Hello,
In my "Add classified" form I am trying to automatically create a one-to-many relationship where parent is always the current user (profile). None of the followings works:
[cred_field field='@profilo-classified.parent' class='form-control' output='bootstrap' author='$current' value='[wpv-post-id item="wpv-current-user"]']
[cred_field field='@profilo-classified.parent' class='form-control' output='bootstrap' author='$current' value='[wpv-post-id item="wpv-user-id"]']
[cred_field field='@profilo-classified.parent' class='form-control' output='bootstrap' author='$current' value='[wpv-user field="id"]']
[cred_field field='@profilo-classified.parent' class='form-control' output='bootstrap' author='$current' value='$current']
[cred_field field='@profilo-classified.parent' class='form-control' output='bootstrap' author='$current' value='wpv-post-author']
[cred_field field='@profilo-classified.parent' class='form-control' output='bootstrap' author='$current' value='[wpv-post-id item="@profilo-classified.parent"]']
Actually users don't need to see this field so I'd prefer a generic field like this:
[cred_generic_field type='hidden' field='@profilo-classified.parent']
{
"default":"[wpv-current-user info='id']" (this doesn't work either ...)
}
[/cred_generic_field]
Please help, thanks
Regards
Nicola

#2800602

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I would like to understand the structure you have.

As I understand you have custom post type "profilo" that holds the user profile and every user will have one user profile post with custom post type "profilo". Is that correct? If yes:
- To identify the what profile post belongs to what user you set the post author so we know what profile post belongs to what user.

Can you please share all above information is correct or if its different how its setup.

#2800662

Exactly right Minesh,
I am trying to create the relationship between the classified that the user is adding and its own profile (that is just an extension of the user profile). With the relationship I will be able to show profile (parent) info on the single classified CT.

#2800967

Christopher Amirian
Supporter

Languages: English (English )

Hi,

This is Christoper. I wanted to mention that Minesh will be available tomorrow to follow up with the ticket.

Thank you for your patience.

#2801080

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

ok - Can you please share admin access details and where you exactly added the form on what page and let me review the current strcture, one I review that I will be able to guide you in the right direction.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2801140

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now.

I've created the following view that is set to query your profili post type and I've added the Query Filter for post author where post author is current loggedin user and this view will return the post ID of profili post.

Post author filter
Select posts with the author the same as the current logged in user.

=> hidden link

Now, with your form I've adjusted the parent field as given under:
=> hidden link

[cred_generic_field type='hidden' field='@profilo-classified.parent']
{
"default":"[wpv-view name="get-loggedin-user-profilo-post-id" cached="off"]"
}
[/cred_generic_field]

So as default value with the above parent field it will have correct profilo post ID.

Can you please confirm now when you add new classified post you able to see its connected to correct profile post.