I'm using a different login element, and it sets everyone as a subscriber.
I'm setting up a membership site where founders can submit their companies and get access to the startup page. After they register as a subscriber they fill out a post form to list their startup.
I don't want subscribers to have access to anything except the homepage. And I don't want people to get access to the startups page for free without listing their startup first.
Is there a way, once their post is approved/submitted that we could change their role to either author or a custom user type "Founder"?
Hi,
Thank you for contacting us and I'd be happy to assist.
To approve a user's post and change the user's role, you can create a post edit form. In that form' settings, you can set it to change the post's status to the approved/published status.
And using the custom function attached to the 'cred_save_data' hook, you can change that post's author role to the desired 'approved' user role:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
You'll find an example of such a function in this forum ticket:
https://toolset.com/forums/topic/updating-user-role-when-submitting-a-form/
I hope this helps and please let me know if you need further assistance.
regards,
Waqar
Here's what I did:
add_action('cred_save_data', 'change_user_role_on_save',10,2);
function change_user_role_on_save($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==302)
{
$user = wp_get_current_user();
if ( in_array( 'subscriber', (array) $user->roles ) ) {
// Remove role
$user->remove_role( 'subscriber' );
// Add role
$user->add_role( 'founder' );
}
I put this in the custom code under settings (didn't work)
I then put it in the JS on the form and it didn't work.
Is there something you can see wrong?
I was able to sort through that issue.
But now as I'm working on the post edit form, I'm running into issues.
I'm using elementor so I'm using the shortcode: [cred_form form='post-edit-startups' post='[wpv-search-term param=“post_id”]
The link to edit the post is: hidden link;
It worked for minute and then started displaying: "Form type and post type do not match" -- I've looked through every post on here about that error, and normally it's because the category wasn't matched correctly, or wordpress needed updates. All of my plugins are up to date, and it's mapped correctly.
Is there any other troubleshooting tips?
Thanks for the update and glad that it was sorted out.
I've created a separate ticket for your new question and will follow up on that shortly.
( ref: https://toolset.com/forums/topic/split-using-shortcode-within-shortcode-in-elementor/ )
You're welcome to mark this ticket as resolved and start a new one for each new question or concern.