• Resolved iltdevunit

    (@iltdevunit)


    Hi,

    I’m trying to programatically set an image to have a specific MCM category.

    This is the code I’m using:

    wp_set_post_terms( $imageID, array(13), 'category_media', true );

    It does work, as I can see in the dashboard that the category has been applied, but I get this error:

    Warning: call_user_func() expects parameter 1 to be a valid callback, function 'mcm_update_count_callback' not found or invalid function name in wordpress\wp-includes\taxonomy.php on line 3662

    any ideas what could be wrong?

    https://www.ads-software.com/plugins/wp-media-category-management/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author DeBAAT

    (@debaat)

    Hai

    Are you possibly using your code on the front-end or for non-admin users?
    The function mentioned is defined in the file “wp-mcm-admin-functions.php” which is only loaded for admin use.

    Thread Starter iltdevunit

    (@iltdevunit)

    Hi there,

    Yes I am calling this on the front end.
    I have a custom profile template (using Theme My Login) and allow the user to select their avatar and update their profile.

    When the page reloads, the avatar is shown in the header and at this point the I set the avatar image’s category to 13.

    Is there a workaround for this?

    Thread Starter iltdevunit

    (@iltdevunit)

    I came up with this to load the mcm functions on my custom profile page.
    I added the following to my theme’s functions.php page.

    $post_id = url_to_postid( $_SERVER['REQUEST_URI'] );
    $post = get_post($post_id);
    $slug = $post->post_name;
    if($slug=='my-account'){
       if ( ! is_admin() ) {
          include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
       }
    
       if ( is_plugin_active( 'wp-media-category-management/wp-media-category-management.php' ) ) {
          require_once( ABSPATH.'wp-content\plugins\wp-media-category-management\include\wp-mcm-admin-functions.php' );
       }
    }

    I’m open to suggestions ??

    Plugin Author DeBAAT

    (@debaat)

    Ah, that could work.

    Maybe better, try to load the admin functions in the plugin itself.
    To do this, comment out lines 64 and 66 in file “wp-media-category-management.php” like this:

    63   // load code that is only needed in the admin section
    64   //if ( is_admin() ) {
    65   	require_once( WP_MCM_DIR . '/include/wp-mcm-admin-functions.php' );
    66   //}

    I’ll see whether I can help out in the next release.

    Thread Starter iltdevunit

    (@iltdevunit)

    Thanks for the suggestions ??

    Plugin Author DeBAAT

    (@debaat)

    Hai,

    I just uplaoded V1.7.0.
    Can you test again please?

    Gr.
    Jan

    Thread Starter iltdevunit

    (@iltdevunit)

    Hi,

    Yes that works fine ??

    Plugin Author DeBAAT

    (@debaat)

    Thanks for reporting back.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Warning: call_user_func() expects parameter 1 to be a valid callback’ is closed to new replies.