Skip Navigation

[Resolved] Post only one post per author.

This support ticket is created 3 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

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)

Author
Posts
#1961797

Hi, I'm setting a an experts database with toolset and it's a lot of fun with the huge abillities of Toolset. But before I do it in the absolute wrong way I need an hint is this correct what I'm doing. Forgive me my bad english.

1. I created a custom post type for the experts, where each expert can insert data about her/him.
2. A new expert can register with a standard user form (ultimate member).
3. After a review his account get activated and he can enter his data over a Toolsets form in the new post type
4. Over another menu entry he can edit existing data for himself.

But now I have two questions. How can I prevent that an expert will create more than one entry? Is it the right way first register a wordpress user and keep the experts date in a seperate post type? Later experts have to pay for there entries, therefore on the registration process they shall not allowed to enter data. After the payed the can enter data.

Thanks in advance

#1962499

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

What we can do is when user is registered, we can create one entry under the custom post type experts and set the author of this post as the currently registered user.

So, later we can find how many experts posts are available belongs to the currently loggedin user. I'm not sure how you want to track the payment or what will be the exact flow. Do you want to use the Toolset Forms Commerce for payment?

#1962523

The payment will made with "Ultimate member" plugin, not with Toolset.

Your suggestions sounds great. How can I generate a post after the user has registered automaticly, as you suggested?

#1962525

Minesh
Supporter

Languages: English (English )

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

For that I will require to know what registration form you are going to use? From "Ultimate member" or using Toolset Form?

#1962531

I use the Ultimate member form. I'm not sure if I can use a Toolset form because later we add the payment process on registration.

#1962533

Minesh
Supporter

Languages: English (English )

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

So, then the ticket belongs to "Ultimate Member" plugin as you are not going to use Toolset.

Ultimate Member offers some hook "um_registration_complete" as you can see below:
- hidden link

You should try to use that hook and hook your code that should generate the new post for your post type using the WordPress function: wp_insert_post()
- https://developer.wordpress.org/reference/functions/wp_insert_post/

#1962657

Ok, I understand. Thanks.

But, would it be possible to do the User registration process directly with Toolset?

#1962675

Minesh
Supporter

Languages: English (English )

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

Yes - Toolset offers User forms for registration.

More info:
https://toolset.com/course-lesson/creating-forms-for-registering-users/

#1962679

Ok, thanks. Maybe this is a better way. And how can I then add automaticly a post to the expert CPT after registration?

#1962687

Minesh
Supporter

Languages: English (English )

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

You can use the Toolset Form hook - cred_save_data.

You can add the following code to your current theme's functions.php file.

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data) {

if ($form_data['id']==9999){

$user_id = $post_id;
// Create new entry after registration.
$my_post = array(
'post_title' => "your title",
'post_content' => '',
'post_status' => 'publish',
'post_author' => $user_id,
'post_type' => 'post-type-slug'
);

// Insert the post into the database
wp_insert_post( $my_post );
}
Where:
- Replace 9999 with your user form ID
- adjust the code with your original post type and title.

More info:
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

#1962691

Thanks a lot for this great support and your help. I see, Toolset is the right tool for me and I'll use it in future on many other sits.

#1962703

Minesh
Supporter

Languages: English (English )

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

Glad to know that solution I shared will help you to build the feature you want with your site.

Please feel free to mark resolve this ticket 🙂

#1962711

My issue is resolved now. Thank you!