• Resolved GermanKiwi

    (@germankiwi)


    Hi, I’m using this plugin along with the Genesis Framework theme, and a Genesis child theme that has its own functions.php funtionality. I prefer to use Code Snippets however.

    I’ve encountered something odd with one snippet of code though – see below. When I add this code to my theme’s own functions.php, it works perfectly (it removes all of the mentioned profile fields from the User profile page).

    But if I remove it from my theme’s functions.php and add it to Code Snippets instead, it only removes the AIM, YIM and Jabber fields, but does not remove the Google+ or Twitter fields. I have no idea why. Can anyone offer a reason?

    Here’s the code:

    function hide_profile_fields( $contactmethods ) {
    	unset($contactmethods['aim']);
    	unset($contactmethods['yim']);
    	unset($contactmethods['jabber']);
    	unset($contactmethods['googleplus']);
    	unset($contactmethods['twitter']);
    	return $contactmethods;
    }
    add_filter('user_contactmethods','hide_profile_fields',10,1);

    http://wordpress.org/plugins/code-snippets/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    I have fiddled around with your snippet and found that you can get it working if you increase the filter priority. Like:

    add_filter( 'user_contactmethods', 'hide_profile_fields', 999, 1 );

    I think that this has to do with how snippets are executed much earlier than functions.php files.

    Thread Starter GermanKiwi

    (@germankiwi)

    Thanks – that’s done the trick nicely!

    Thread Starter GermanKiwi

    (@germankiwi)

    Actually there’s one other snippet that I’m having trouble with – maybe you can help too. I think it might also be related to priority, but I’m not sure how to change that in this case, because it’s using the “add_editor_style” function:

    add_editor_style( dynamik_get_stylesheet_location('url') . 'genesis-column-classes.css' );

    I have this currently in my theme’s functions.php file but I’d like to move it to a snippet. As you can see, it looks like it is a theme-specific function because it references “dynamik” which is the name of my Genesis child theme.

    My guess is that this snippet runs before WordPress has been informed of the path that “dynamik_get_stylesheet_location” equates to.

    Any ideas?

    Plugin Author Shea Bunge

    (@bungeshea)

    Placing all of the code inside a function hooked to the init action. This action runs after all of the plugins and the theme has loaded

    add_action( 'init', function() {
        add_editor_style( dynamik_get_stylesheet_location('url') . 'genesis-column-classes.css' );
    });
    Thread Starter GermanKiwi

    (@germankiwi)

    Thanks again!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Snippet doesn't work fully’ is closed to new replies.