Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • @ericwillson

    Participant

    You r welcome If the activity form is related to BuddyPress you might want to check BuddyPress specific functions or hooks in your theme or plugin files. BuddyPress indeed has its own set of functions for handling activities and forms.

    @ericwillson

    Participant

    To find the specific function responsibl for creating the activity form
    Check the theme’s functions.php file Look for a related function in your active theme functions.php file
    Inspect plugin files If the form is part of a plugin, search for relevnt functions within the plugin’s PHP files.
    Search documentation Consult the plugin or theme documentation for information on activity form functions
    Use a code editor/IDE Utilize search feature in your code editor/IDE to find keywords related to the activity form.
    Contact the develper If needed, reach out to the theme or plugin developer for specific function details.
    Once you identify the function, replace ‘function_that_creates_activity_form’ in the provided code snippet with the actual function name to disable the activity form for non-admin users.

    @ericwillson

    Participant

    opps ] Let me provide you with an alternative approach that disables the activity form for users, making it more secure. You can achieve this by disabling the form functionality entirely. Here how you can modify the code to accomplish thi

    php
    Copy code
    function disable_activity_form_for_non_admins() {
    if ( ! current_user_can( ‘administrator’ ) ) {
    remove_action( ‘init’, ‘function_that_creates_activity_form’ );
    }
    }
    add_action( ‘init’, ‘disable_activity_form_for_non_admins’ );

    In this code snippet, replace ‘function_that_creates_activity_form’ with the actual function name or hook that creates the activity form. This modification disables the activity form functionality for non-administrative users by removing the action that creates the form during the init hook.

    This way the form wont be available in the HTML markup, making it more secure compared to just hiding it with CSS. Remember to place this code in your theme’s functions.php file or in a custom plugin file.

    Again make sure to back up your site before making any changes, and test the modified code in a safe environment first to ensure it works as expected. If you encounter any issues or have further questions, feel free to ask!

    @ericwillson

    Participant

    To achieve the functionality you described, you can add the following PHP code snippet to your WordPress plugin or theme’s functions.php file. This code will hide the activity form from all users except admins:

    php
    Copy code
    function hide_activity_form_for_non_admins() {
    if ( ! current_user_can( ‘administrator’ ) ) {
    ?>
    <style type=”text/css”>
    .activity-form-class {
    display: none;
    }
    </style>
    <?php
    }
    }
    add_action( ‘admin_head’, ‘hide_activity_form_for_non_admins’ );

    In this code snippet:

    current_user_can(‘administrator’) checks if the current user is an administrator.
    If the current user is not an administrator, it adds a <style> block to the <head> of the admin pages, setting the CSS property display: none; for the element with the class activity-form-class. Make sure to replace activity-form-class with the actual class name or ID of the activity form element in your HTML markup.
    EXP3RTS ensures you have a backup of your site or are comfortable with making changes to your theme/plugin files before adding this code. Additionally, modify the class name in the code to match the actual class or ID of your activity form for it to work correctly.
    I HOPE THIS IS BENEFICIAL FOR YOU

Viewing 4 replies - 1 through 4 (of 4 total)
Skip to toolbar