Skip to:
Content
Pages
Categories
Search
Top
Bottom

Check xProfile Field exists


  • javierllinas
    Participant

    @javierllinas

    Hello,

    I want to display a warning notice in wp-admin if certain xProfile field doesn’t not exist. Something like:

    if ( !xprofile_get_field_id_from_name('My_xProfile_Custom_Field') ) {
    
        add_action( 'admin_notices', 'sample_admin_notice__warning' );
    
    }

    My approach above is really wrong, I guess.

    I appreciate any help.

    WP -> 4.5.2
    BP -> 2.5.2

    Thank you!

Viewing 1 replies (of 1 total)

  • javierllinas
    Participant

    @javierllinas

    This is what I came up with:

    function sample_admin_notice__warning{
        if ( xprofile_get_field_id_from_name('My xProfile Custom Field') ) {
            return;
        }
        $class = 'notice notice-warning';
        $message =  __( 'Please, add new "My xProfile Custom Field" Profile Field','textdomain');
    
        printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
    }
    add_action( 'admin_notices', 'sample_admin_notice__warning' );

    It does the job, what do you guys think?

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar