• Resolved neon67

    (@neon67)


    Thanks for the helpful plugin!
    How to make the value of the field “Enter label eg Town, City, State ….” displayed by default? (in your example “Name:”) If the user did not enter their value, of course …

    Is it customizable?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Robin W

    (@robin-w)

    so this is just on the user profile part – yes ?

    so when the user goes in to complete, the field is prefilled and if they do not alter, then that is saved ?

    or do you also want it on the display part if they have not filled anything in ?

    Thread Starter neon67

    (@neon67)

    Script: first field filled by admin already. For example – “man”.

    1 way. If the user doesn’t pay attention for this non-optional field, the “man” remains.
    2 way. If erasure and fills in own word – it can be anything – “woman”, “boy”, etc. – such individual mark shown, and not by default “man”.

    Is it difficult to set up? Thanks.

    Explanation of why this is necessary for me: I have more than 3000 users and would like to make a general default brand. If the user wants, he will specify the brand through own profile.

    • This reply was modified 4 years, 3 months ago by neon67.
    Plugin Author Robin W

    (@robin-w)

    ok thanks, let me take a look

    Plugin Author Robin W

    (@robin-w)

    I looked at possibilities. I don’t have enough time to rewite parts of the code to do exactly what you want within the code, but I’ve just released version 1.8.3. Upgrade to this first.

    This now has some hooks that we can use.

    Put the following code in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

    where %your-theme-name% is the name of your theme

    or use
    https://en-gb.www.ads-software.com/plugins/code-snippets/

    add_filter ('rpi_user_profile_field', 'rew_default', 10, 2 ) ;
    add_filter ('rpi_profile_information', 'rew_default', 10, 2 ) ;
    
    function rew_default ($data, $label_id) {
    	if ($label_id == 'rpi_label1' && empty ($data)) $data = 'man' ; 
    	if ($label_id == 'rpi_label3' && empty ($data)) $data = 'elephant' ; 
    return $data;
    }

    This will make items 1 & 3 have labels of man and elephant

    so add or remove the ‘if’ lines and change the words to whatever default to get what you need.

    eg

    add_filter ('rpi_user_profile_field', 'rew_default', 10, 2 ) ;
    add_filter ('rpi_profile_information', 'rew_default', 10, 2 ) ;
    
    function rew_default ($data, $label_id) {
    	if ($label_id == 'rpi_label1' && empty ($data)) $data = 'man' ; 
    return $data;
    }
    add_filter ('rpi_user_profile_field', 'rew_default', 10, 2 ) ;
    add_filter ('rpi_profile_information', 'rew_default', 10, 2 ) ;
    
    function rew_default ($data, $label_id) {
    	if ($label_id == 'rpi_label1' && empty ($data)) $data = 'man' ; 
    	if ($label_id == 'rpi_label3' && empty ($data)) $data = 'elephant' ; 
            if ($label_id == 'rpi_label4' && empty ($data)) $data = 'ostrich' ; 
    return $data;
    }
    Thread Starter neon67

    (@neon67)

    Thanks, it works as it should. But there was a problem.
    If delete the default word “man” in user profile, the user’s avatar(pic.) also deleted…. I use the popular WP User Avatar plugin.
    Apparently they are incompatibility.

    Can to fix something here?….

    Plugin Author Robin W

    (@robin-w)

    interesting……

    so in bbpress profile, you go into a user and delete the entry and click save, and the avatar disappears from where? everywhere, just topics/replies etc.

    • This reply was modified 4 years, 3 months ago by Robin W.
    Thread Starter neon67

    (@neon67)

    everywhere. The personal picture is deleted, the default picture appears.

    Plugin Author Robin W

    (@robin-w)

    ok, really strange.

    so if you take my filter code out of your functions file , and then just have my profile plugin running, if you change a user to ‘man’ and save and then delete ‘man’ and save, does the problem occur – just seeing if the issue is with the filter or the plugin!

    Thread Starter neon67

    (@neon67)

    Congratulations, the filter is very good! Works very well for users, the avatars do not disappear – changed the field value many times!
    The problem is only for Admin – if he changes the user’s profile – the personal picture disappears, and the default pic appears. But even for the Admin, everything works well if he works in the admin area.

    Yes! And this error for the Admin only is not related by the filter – without this filter the same leap. The problem was even before the filter appeared in the php function.

    Thank you very much for your Work!

    Plugin Author Robin W

    (@robin-w)

    great that’s good news – can I mark this one as fixed?

    Thread Starter neon67

    (@neon67)

    Yes, it’s a victory)
    The problem with Admins will be addressed in the Avatar Plugin bundle.

    Thanks again!

    Plugin Author Robin W

    (@robin-w)

    no problem !

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How Customize the first field to show by default’ is closed to new replies.