Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Force Simple Press to use intials as profile display name.
Avatar
Ryan Minnaar
Member
Free Members
sp_UserOfflineSmall Offline
Jun 14, 2013 - 3:25 pm

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. 

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jun 14, 2013 - 3:38 pm

Take a look at the forum admin > Profiles > Profile Options - Display Name Format.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Ryan Minnaar
Member
Free Members
sp_UserOfflineSmall Offline
Jun 14, 2013 - 3:53 pm

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

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jun 14, 2013 - 5:01 pm

You are right - I missed that.

So - we could do this using a WordPress style filter action. Do you know how to use these? I would be happy to add a new one into the code where needed so it can be used...

andy-signature.png
YELLOW
SWORDFISH
Avatar
Ryan Minnaar
Member
Free Members
sp_UserOfflineSmall Offline
Jun 15, 2013 - 5:48 am

Hi 

No i'm afraid not, I have just enough coding knowledge to be dangerous. I would be very grateful if you could help directly. What would you need from my side? 

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jun 15, 2013 - 10:42 am

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.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Ryan Minnaar
Member
Free Members
sp_UserOfflineSmall Offline
Aug 14, 2013 - 9:47 am

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. 

 

 

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Aug 14, 2013 - 9:53 am

Did answer in the Pm already....

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17361
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625