Skip Navigation

[Resolved] Setting up user accounts for members

This thread is resolved. Here is a description of the problem and solution.

Problem:

I'm still confused about how to set up User accounts that link to Member posts.

Solution:

In your case, it should be like this:

1) User register and login into your website

2) In a WP page, for example "My account", display a post view:

- Query "Members" posts

- Filter by Post author is same as logged in user

https://toolset.com/documentation/user-guides/views/filtering-views-query-by-author/

- If there isn't any item found, display a post form for creating new "Members"

Relevant Documentation:

https://toolset.com/documentation/legacy-features/views-plugin/how-to-create-custom-searches-and-relationships-for-users/

This support ticket is created 3 years, 5 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 16 replies, has 2 voices.

Last updated by elizabethS-6 3 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#1816527

Hi there,

I have created a custom post type called Members, and I want to move in the members we have from our old site. I'm just not sure of the best way to do that, because I know members will also need to have User accounts in WordPress. I followed the documentation but I'm still confused about how to set up User accounts that link to Member posts. Do I need to set up the form first and add members that way?

The site can be found here: hidden link (username: copper, password: delirious)

Thank you!

#1817249

Hello,

I assume you are going to setup relationship between other post types and "Members".

If it is, please check out document:
How to Create Custom Searches and Relationships for Users
https://toolset.com/documentation/legacy-features/views-plugin/how-to-create-custom-searches-and-relationships-for-users/

In your case, it should be like this:
1) User register and login into your website
2) In a WP page, for example "My account", display a post view:
- Query "Members" posts
- Filter by Post author is same as logged in user
https://toolset.com/documentation/user-guides/views/filtering-views-query-by-author/
- If there isn't any item found, display a post form for creating new "Members"

#1818153

Hi, thank you for your response, this is helpful.

I've already added some members from our old site into the custom post type I created for members in Toolset. It sounds like I need to create user profiles for them first though, is that correct?

If I have a user profile for a member and I want to link it to their member post, can I do that from the back end using the post author field? Or do I have to set up the form, log in as them, and enter their member info that way in order for it to link properly?

I'm just wondering because we want to move members over from our old site without making them submit a form again. I don't see where the post author field in my custom post type. I was thinking maybe I could create one, and just make sure it matches the username on the user accounts I set up. But I'm guessing it's more complicated than that.

Thanks very much!

#1818675

Yes, you will need to setup the "Member" post author as different WordPress user, you can try these:
1) Dashboard-> Toolset-> Post Types, find and edit "Member" post type, in section "Sections to display when editing", enable option "Author", save
2) Edit each "Member" post, setup the post author

#1822709
Screen Shot 2020-10-23 at 12.29.15 PM.png
Screen Shot 2020-10-23 at 12.29.47 PM.png
Screen Shot 2020-10-23 at 12.30.31 PM.png

Thank you! I set up user accounts for the members I want to import. I used Toolset to created a new role called "Member" and I made sure they had the same permissions as Authors:

upload_files

edit_posts
edit_published_posts
publish_posts
read
delete_posts
delete_published_posts

I also followed your instructions to make sure the Author option appears when I go in to edit my custom "Member" posts. However, I'm not seeing my members show up in the author dropdown, only admins are showing up right now. What am I missing?

Thanks again!

#1822739

Hi there, I just wanted to say that I tried adding this code snippet based on another Toolset support ticket I found, but so far it's not changing the dropdown:

function wpdocs_add_members_to_dropdown( $query_args, $r ) {
 
    $query_args['role'] = array('member');
 
    // Unset the 'who' as this defaults to the 'author' role
    unset( $query_args['who'] );
 
    return $query_args;
}
add_filter( 'wp_dropdown_users_args', 'wpdocs_add_members_to_dropdown', 10, 2 );
#1824365

It is a custom codes problem, if you need more assistance for it, please provide a test site with the same problem, also point out:
1) The problem page URL
2) Where I can edit your custom PHP codes.

#1825451

I have tried the credentials you provided above, it is not valid, I get 404 error, please check it, make sure it is valid, and also point out the problem page URL, where I can see the problem in front-end, thanks

#1825455

Hi, I'm sorry, I think it's because my computer was asleep. I just tested the link I gave you and it worked. Can you please try again? I've changed my settings so sleep mode will not activate.

I'm trying to link my custom post type called "Advisors" to their corresponding WordPress User accounts using the Author field. If you go to this URL you can find links to the individual advisor pages I'm trying to set up: hidden link

Thanks very much and sorry for the login trouble. I really hope it works this time.

#1825485
wp-admin.JPG

I have tried it again, but after login I get PHP errors:
Recoverable fatal error: Object of class stdClass could not be converted to string in /Users/elizabethstewart/Local Sites/galliard/app/public/wp-content/mu-plugins/local-by-flywheel-live-link-helper.php on line 154

See my screenshot, please check it

#1825517

I don't understand, when did you get that error? Just from logging in as an admin? I don't understand how to check that or what I'm supposed to change. I didn't do anything to PHP except add that code snippet I got from the other support ticket. Do I need to ask my hosting provider to explain what's going on? I'm starting to feel like Toolset might be too hard for me. 🙁

#1825539

Yes, just login your website and get the PHP errors, I have checked it again, same PHP errors, you can provide a copy of your website in below private message box, I need to test it in my localhost.
https://toolset.com/faq/provide-supporters-copy-site/

#1826315

Hi there, I just wanted you to know that I contacted my host and they were unable to replicate the issue you're experiencing on the local site. They didn't see any fatal errors. They recommended I create a new demo site and push the local site there, so I've done that.

Here's the link to the demo site: hidden link.

Your admin credentials should still work. To get past the privacy screen, please use flywheel for the username and jaded-zeal for the password. Thanks again, I hope this works better.

#1826699

Thanks for the details, I can login your website and see the problem.

The problem is filter hook "wp_dropdown_users_args" works only in classic editor, it does not work in Blocks editor.

I have done below modification in your website, edit post type "Advisors":
hidden link
option "Editor (required)" choose "Classic".

Test it here:
hidden link
At the page bottom, I can see it works fine, please check it

#1826717

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.