Support Forum
Hi
I have a bit of a tricky setup I please need advice on. I have a custom Wordpress Theme running Woocommerce and Wishlist Member.
By default Woocommerce creates a Wordpress username by combining the persons first name and their last name. In turn I have Simple Press setup to add those members to the forum.
Here's the "problem" the forum is supposed to be an anonymous platform and members are requested to change their Profile Display Name, but it does initially show the full name on the forum. Is there a way to force Simple Press to use their initials as an initial member name and then allow them to change it later?
I look froward to any help on this.
Thanks.
Thanks for the quick reply. I did do that a few minutes ago and I did set it up to use first and last initials. The part that concerns me though is it says " Display name format if member cannot choose (ignored if member allowed to choose)"
I do allow them to choose and I have the "Let member choose display name" selected. I have not done an actual test yet (requires registration and payment etc etc), I wanted to make sure that by setting it up as I have above that it would actually make their initial member name initials even though they are allowed to choose.
If it won't work and I don't allow them to choose (to make it work) is there still a way they can change it later?
Thanks again
OK. First up - please remember that I am unable to test this immediately. it should work but it might need some correction along the way. So please bear with me on this.
If this works then I can ensure that the filter call is placed in core code for the next release so your code will continue to work after the next update you make to the Simple:Press core.
So first - we need to make a small edit to a core code file. This file is:
/wp-content/plugins/simple-press/sp-api/sp-api-users.php
You need the function called sp_create_member_data() which is the second function in the file.
After the case statement locate this line of code:
$display_name = sp_filter_name_save($display_name);
Add the first line below ABOVE this line of code as shown:
$display_name = apply_filters('sph_set_display_name', $display_name, $userid); $display_name = sp_filter_name_save($display_name);
And save the file. Now open the spFunctions.php file of the Simple:Press Theme you are using (in the templates folder of the theme).
Add this code somewhere in that file:
add_filter('sph_set_display_name', 'setup_display_name', 1, 2); function setup_display_name($display_name, $userid) { $first_name = get_user_meta($userid, 'first_name', true); $last_name = get_user_meta($userid, 'last_name', true); return $first_name[0].$last_name[0]; }
As I have said - this is completely untested. if it does not work it will probably be a typo or something on my side. But try it by registering a new user to see if it saves the initials as the display name.
Let me know.
YELLOW
SWORDFISH
|
Hi
I sent a PM on this, but better to put it on the forum My question is now that the new version has been released (and I have installed it) and I am now ready to try your suggestions, is the advice above still valid?
Is there anything new I need to do or can I follow the instructions above to accomplish what I need? Just a reminder that I am trying to force SP to use user initials and not full name when they get registered through Whishlistmember.
As always thanks for the help. I look forward to your response.
1 Guest(s)