• Hi,

    I have AMR User list plugin and i have also added additional fields inside User Profile form through WP Members plugin.
    Now i have a field for Email and one checkbox that asks users if they want to publish that email or make it Public. If users checks this box then email should not be displayed in the user list.

    How can i achieve this in the AMR Plugin? Is there a way through which i could establish relationship between these two fields and display email address only if Publish Email checbox is checked?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author anmari

    (@anmari)

    HI,
    A custom format routine for the email field is probably best:
    Read https://wpusersplugin.com/2645/format-any-field-any-way-you-wish/ or https://wpusersplugin.com/2823/formatting-and-pluggable-functions/

    To decide whether to display the email, in your custom formatting routine for the field you could do something like

    ausers_format_the_selectively_displayed_field($v, $u) {
    
    if (isset($u[thechecboxthatsaysdonotdisplay]) and ($u[thechecboxthatsaysdonotdisplay]="thevaluethatsaysdont"))) {
             return ('');
        else return ($v);
    }
    }
    • This reply was modified 8 years, 5 months ago by anmari.
    Thread Starter amishi

    (@amishi)

    Hi,

    Thank you for your response. I checked your code and tried to use this but it is not working. Nicenames for my fields were:
    User Email: user_email
    Publish Email: pubemail (When it was checked 1 value was stored)

    if (!function_exists('ausers_format_user_email')) {
    	function ausers_format_user_email ($user_email,$pubemail) {
    		if (isset($pubemail) and ($pubemail == "1")) {
             return ($user_email);
        }else{
        return ('Not Allowed');
    		}
    	}
    }

    This is the code that i am using in the ausers-pluggable.php, but it is always going in else condition. Can you please help?

    Plugin Author anmari

    (@anmari)

    amishi,

    You maybe able to sort this out yourself IF you please read the links in the posts above and see HOW the posts advised you to add the code – a separate site specific plugin or of you have custom theme, then in your functions.php.

    Functions that are being ‘plugged’ need to load before the functions in the plugin. The pluggables file is specially setup to load late so that custom functions will overwrite it. So DO NOT put the code in the pluggables file as that may NOT work – your function may be loading too late.

    Also it is NOT good practice to edit wp or plugin source code. Your changes will be overwritten if you apply an update. This is why the plugin offers filters and pluggable functions, so that they can sit separate from the main plugin and NOT be overwritten.

    Time is precious – If you need assistance with custom work, please see https://webdesign.anmari.com/about/fees/ – I work in 1/2 hr increments.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display Email in the list only if user has checked to Publish it’ is closed to new replies.